From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id BDB036EC40; Thu, 12 Aug 2021 20:52:39 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BDB036EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628790759; bh=Ts+GJ1DSS6sX5GOdjp2uhIE6xSIlsn+IBfiixeetW5Q=; h=To:Cc:References:Date:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=YNJoqRr8Vvud1FWRTW3VEo2oWtFcwF5nw96vI0sYpidcar8gpDLgtiazwkP8D4GW2 OFOLwp5KVh52mCoehN+iKQmRabfo2hYl4qVYI3N4WoJtqa6MR1Wd1AXElzgf+HjpEG 3vim9eZHa3GIbKFd1ZUZwRH1R5RKeYgQtVmrAG1Q= Received: from smtp34.i.mail.ru (smtp34.i.mail.ru [94.100.177.94]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id C207B6EC40 for ; Thu, 12 Aug 2021 20:52:37 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C207B6EC40 Received: by smtp34.i.mail.ru with esmtpa (envelope-from ) id 1mEEse-0005AN-1D; Thu, 12 Aug 2021 20:52:37 +0300 To: mechanik20051988 , tarantool-patches@dev.tarantool.org, vdavydov@tarantool.org Cc: mechanik20051988 References: <01ad18203fb09e1e4f1cb26e9a7db83a4d1e9087.1628759886.git.mechanik20051988@tarantool.org> Message-ID: <8a02aa62-0159-e535-174a-bcb1a5edf6b4@tarantool.org> Date: Thu, 12 Aug 2021 20:52:30 +0300 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <01ad18203fb09e1e4f1cb26e9a7db83a4d1e9087.1628759886.git.mechanik20051988@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD9F9A2272A1D086A28553D1D5C4B4124EF182A05F538085040AF64FE8E5125B954B27422EE60BE1D545F7D096338E40D0E0027F9E12C6FE625 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F1942E6D70B4A2F0EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637D4360D888D8F9BE48638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8A1EE286F2475B6DA08CDB78763CD6BC7117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC44DFDAE72D78788F389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC816F36C0CB6DCE122F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CDA532D2019E286A72D242C3BD2E3F4C64AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C32D7E768E06EC9FDBBA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE74ABCC139FF3F849B731C566533BA786AA5CC5B56E945C8DA X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B5051C903B021F81405A3A8FCD720D219843 X-C1DE0DAB: 0D63561A33F958A5607C076CFB944B388F481E0868CAD2C8300FB0CA04C1231CD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75C136C9B4EE35C541410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34A08F09726D78E07BABC011F3310F7DEB715F28A32DB90F0D24E9EA93288151073A57FD178A76A2701D7E09C32AA3244C9F823A17E87E81B4EC567082C820A958725D5B54B2FE4575927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojKW4rnL99YhIQcRLEHdbbCw== X-Mailru-Sender: DCB18673505F245B5D9D3B35E842BD3CCEAE9F6785110862369AD917CBE69162EFD9FE33A6421891841FB911095AA09146E8006E22572C39C920B61C43410E8717BDA556287159EE9437F6177E88F7363CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v4 9/9] net.box: add interactive transaction support in net.box X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Vladislav Shpilevoy via Tarantool-patches Reply-To: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Thanks for the patch! See 3 comments below. > diff --git a/changelogs/unreleased/gh-5860-implement-streams-in-iproto.md b/changelogs/unreleased/gh-5860-implement-streams-in-iproto.md > new file mode 100644 > index 000000000..8a8eec3e7 > --- /dev/null > +++ b/changelogs/unreleased/gh-5860-implement-streams-in-iproto.md > @@ -0,0 +1,26 @@ > +## feature/core > + > +* Streams and interactive transactions over streams are implemented > + in iproto. Stream is associated with it's ID, which is unique within > + one connection. All requests with same not zero stream ID belongs to > + the same stream. All requests in stream processed synchronously. The > + execution of the next request will not start until the previous one is > + completed. If request has zero stream ID it does not belong to stream > + and is processed in the old way. > + In `net.box`, stream is an object above connection that has the same > + methods, but allows to execute requests sequentially. ID is generated > + on the client side automatically. If user writes his own connector and > + wants to use streams, he must transmit stream_id over iproto protocol. > + The main purpose of streams is transactions via iproto. Each stream > + can start its own transaction, so they allows multiplexing several > + transactions over one connection. There are multiple ways to begin, > + commit and rollback transaction: using appropriate stream methods, using > + `call` or `eval` methods or using `execute` method with sql transaction > + syntax. User can mix these methods, for example, start transaction using > + `stream:begin()`, and commit transaction using `stream:call('box.commit')` > + or stream:execute('COMMIT'). > + If any request fails during the transaction, it will not affect the other > + requests in the transaction. If disconnect occurs when there is some active > + transaction in stream, this transaction will be rollbacked, if it does not > + have time to commit before this moment. 1. Please, add a reference to the ticket in the end in the form `(gh-####)`. > diff --git a/src/box/lua/net_box.lua b/src/box/lua/net_box.lua > index 8d707fb26..f203b203e 100644 > --- a/src/box/lua/net_box.lua > +++ b/src/box/lua/net_box.lua > @@ -754,11 +757,38 @@ local function stream_new_stream(stream) > return stream._conn:new_stream() > end > > +local function stream_begin(stream, opts) > + check_remote_arg(stream, 'begin') > + local res = stream:_request(M_BEGIN, opts, nil, stream._stream_id) > + if opts and opts.is_async then > + return res > + end > +end > + > +local function stream_commit(stream, opts) > + check_remote_arg(stream, 'commit') > + local res = stream:_request(M_COMMIT, opts, nil, stream._stream_id) > + if opts and opts.is_async then > + return res > + end 2. Why can't you just return the result of :_request()? Isn't it supposed to return the correct thing right away? For example, remote_methods:execute() does it, space methods too. > +end > + > +local function stream_rollback(stream, opts) > + check_remote_arg(stream, 'rollback') > + local res = stream:_request(M_ROLLBACK, opts, nil, stream._stream_id) > + if opts and opts.is_async then > + return res > + end > +end > diff --git a/test/box/net.box_iproto_transactions_over_streams.result b/test/box/net.box_iproto_transactions_over_streams.result > new file mode 100644 > index 000000000..c2167e760 > --- /dev/null > +++ b/test/box/net.box_iproto_transactions_over_streams.result <...> > +--- > +... > +-- successful begin using stream:call > +stream:call('box.begin') > +--- > +... > +-- error: Operation is not permitted when there is an active transaction 3. Well, it does not look very successful like you said in the comment. The test seems broken. I didn't validate the others since I have very few time for that. I hope Vova will take a closer look at the tests now despite he has given LGTM already. (Or am I missing something and the test actually succeeds with this weird output on purpose?) > +stream:eval('box.begin()') > +--- > +- error: 'Operation is not permitted when there is an active transaction ' > +... > +-- error: Operation is not permitted when there is an active transaction > +stream:begin() > +--- > +- error: 'Operation is not permitted when there is an active transaction ' > +... > +-- error: Operation is not permitted when there is an active transaction > +stream:execute('START TRANSACTION') > +--- > +- error: 'Operation is not permitted when there is an active transaction ' > +... > +stream:call('ping')