From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id B7D1F30263 for ; Fri, 31 May 2019 15:27:40 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e5dXbiwby8WO for ; Fri, 31 May 2019 15:27:40 -0400 (EDT) Received: from smtp61.i.mail.ru (smtp61.i.mail.ru [217.69.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 70E4F3025E for ; Fri, 31 May 2019 15:27:40 -0400 (EDT) Date: Fri, 31 May 2019 22:27:31 +0300 From: Konstantin Osipov Subject: [tarantool-patches] Re: [PATCH v2 3/8] Get rid of fiber_gc from txn_rollback Message-ID: <20190531192731.GB6141@atlas> References: <5ee05038bc2ce46018425081245bf46df90415d6.1558598679.git.georgy@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5ee05038bc2ce46018425081245bf46df90415d6.1558598679.git.georgy@tarantool.org> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Georgy Kirichenko * Georgy Kirichenko [19/05/23 12:14]: > diff --git a/src/box/box.cc b/src/box/box.cc > index 2a738fa36..4d6515dd4 100644 > --- a/src/box/box.cc > +++ b/src/box/box.cc > @@ -197,7 +197,7 @@ box_process_rw(struct request *request, struct space *space, > return txn_commit_stmt(txn, request); > /* Autocommit mode. */ > if (txn_commit_stmt(txn, request) != 0) { > - txn_rollback(); > + txn_rollback(txn); Please add fiber_gc() here. > return -1; > } > if (txn_commit(txn) != 0) > --- a/src/box/call.c > +++ b/src/box/call.c > @@ -209,13 +209,17 @@ box_process_call(struct call_request *request, struct port *port) > fiber_set_user(fiber(), orig_credentials); > > if (rc != 0) { > - txn_rollback(); > + if (in_txn() != NULL) > + txn_rollback(in_txn()); > + fiber_gc(); > return -1; > } > > if (in_txn()) { > diag_set(ClientError, ER_FUNCTION_TX_ACTIVE); > - txn_rollback(); > + if (in_txn() != NULL) > + txn_rollback(in_txn()); in_txn() is expensive and can not be optimzied out, please use a local variable. > + fiber_gc(); > return -1; > } > > @@ -230,13 +234,17 @@ box_process_eval(struct call_request *request, struct port *port) > if (access_check_universe(PRIV_X) != 0) > return -1; > if (box_lua_eval(request, port) != 0) { > - txn_rollback(); > + if (in_txn() != NULL) > + txn_rollback(in_txn()); > + fiber_gc(); Same here and in other places. > return -1; > } > > index 87fd8b3bc..f677e1d33 100644 > --- a/src/box/txn.c > +++ b/src/box/txn.c > @@ -395,7 +395,7 @@ txn_commit(struct txn *txn) > if (txn->n_new_rows + txn->n_applier_rows > 0) { > txn->signature = txn_write_to_wal(txn); > if (txn->signature < 0) > - goto fail; > + return -1; Why this change? > } > /* > * The transaction is in the binary log. No action below > @@ -423,7 +423,7 @@ txn_commit(struct txn *txn) > txn_free(txn); > return 0; > fail: > - txn_rollback(); > + txn_rollback(txn); > return -1; > } > > @@ -437,11 +437,9 @@ txn_rollback_stmt(struct txn *txn) > } > > @@ -534,11 +530,14 @@ int > box_txn_rollback() > { > struct txn *txn = in_txn(); > + if (txn == NULL) > + return 0; > if (txn && txn->in_sub_stmt) { > diag_set(ClientError, ER_ROLLBACK_IN_SUB_STMT); > return -1; > } > - txn_rollback(); /* doesn't throw */ > + txn_rollback(txn); /* doesn't throw */ > + fiber_gc(); box_txn_rollback() is used in a bunch of places in sql. please fix it to use txn_rollback() and an explicit fiber_gc as well in a follow up patch. Thanks! -- Konstantin Osipov, Moscow, Russia