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 BD12A74141; Thu, 20 May 2021 12:03:10 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BD12A74141 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1621501390; bh=bEk+Gx80PJ+rXBw3Wj1GXHnfxFin0zP1HaaVfh8apus=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=RZKXAkWm0qS+2FwuXLMnMfqQb4YaFFpM8iQ468unVW8oSzOUuUtTq4wTOKnloADwa IM5FryKK/yhQ3hiOjkm8oUNuwmnqaH8OTP3FQeIQcWCqmoRHMbEQNBCWkNdMFuECLO M6KWedHNF12sAx+DZbe5hIwMn+OANuPK2R5jlX+g= Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 7A2DA74141 for ; Thu, 20 May 2021 12:02:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 7A2DA74141 Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1ljeZk-0000ap-Jb; Thu, 20 May 2021 12:02:41 +0300 To: v.shpilevoy@tarantool.org, gorcunov@gmail.com Date: Thu, 20 May 2021 12:02:34 +0300 Message-Id: X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD91B019B01C53E51AF388A0BB768BC527FF0271862FFB192DD00894C459B0CD1B9E765EC26AB55186261D886EFA687EDA1377725EC486409A25A3E3A1F90AE8952 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE70186A8DAAA7CBDB1EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F356C90F3414EBBD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D806CE290968617668E2188CED9B7FEBBF117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC5F0C88D684269EDEA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520CCD848CCB6FE560CF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C17119E5299B287EEAD7EC71F1DB884274AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C330B39F36F4341585BA3038C0950A5D36B5C8C57E37DE458B0BC6067A898B09E46D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7BB1D8AFE8C29F51C731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8183A4AFAF3EA6BDC44C234C8B12C006B7A289833858AF3DF237440E88F7B58C3517C3CE7B0E1684779B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDBF80095D1E17F4578DC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34DA1FE609583D493C66D8AE885550422945AF35CCA4BD313C3642057165AE63ABB8446B1746B153061D7E09C32AA3244CE6CC059EC0A6069A6E95F453F07B57ED5A1673A01BA68E40927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXjRs6glMQaGni5fIfXuS6aD X-Mailru-Sender: 583F1D7ACE8F49BD95918038521BA2AAB49FED91A72D1289950615D38720E4BC3F336FA45750710C424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH 1/3] box: make txn reference the limbo entry 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: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" When a transaction is synchronous it has the same lifespan as the corresponding txn limbo entry. Moreover, txn limbo entry is already used (and will be used more extensively) in some triggers where struct txn is passed by default. Avoid passing the limbo entry to triggers explicitly by referencing it in struct txn. Prerequisite #6032 --- src/box/txn.c | 25 +++++++++++-------------- src/box/txn.h | 2 ++ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/box/txn.c b/src/box/txn.c index 1d42c9113..1fa3e4367 100644 --- a/src/box/txn.c +++ b/src/box/txn.c @@ -765,12 +765,12 @@ static int txn_limbo_on_rollback(struct trigger *trig, void *event) { (void) event; + (void) trig; struct txn *txn = (struct txn *) event; /* Check whether limbo has performed the cleanup. */ if (txn->signature != TXN_SIGNATURE_ROLLBACK) return 0; - struct txn_limbo_entry *entry = (struct txn_limbo_entry *) trig->data; - txn_limbo_abort(&txn_limbo, entry); + txn_limbo_abort(&txn_limbo, txn->limbo_entry); return 0; } @@ -801,7 +801,6 @@ txn_commit_try_async(struct txn *txn) goto rollback; bool is_sync = txn_has_flag(txn, TXN_WAIT_SYNC); - struct txn_limbo_entry *limbo_entry; if (is_sync) { /* * We'll need this trigger for sync transactions later, @@ -819,8 +818,8 @@ txn_commit_try_async(struct txn *txn) /* See txn_commit(). */ uint32_t origin_id = req->rows[0]->replica_id; - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); - if (limbo_entry == NULL) + txn->limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + if (txn->limbo_entry == NULL) goto rollback; if (txn_has_flag(txn, TXN_WAIT_ACK)) { @@ -832,15 +831,14 @@ txn_commit_try_async(struct txn *txn) * assignment to let the limbo rule this * out. */ - txn_limbo_assign_lsn(&txn_limbo, limbo_entry, lsn); + txn_limbo_assign_lsn(&txn_limbo, txn->limbo_entry, lsn); } /* * Set a trigger to abort waiting for confirm on * WAL write failure. */ - trigger_create(trig, txn_limbo_on_rollback, - limbo_entry, NULL); + trigger_create(trig, txn_limbo_on_rollback, NULL, NULL); txn_on_rollback(txn, trig); } @@ -864,7 +862,6 @@ int txn_commit(struct txn *txn) { struct journal_entry *req; - struct txn_limbo_entry *limbo_entry = NULL; txn->fiber = fiber(); @@ -893,15 +890,15 @@ txn_commit(struct txn *txn) * After WAL write nothing should fail, even OOM * wouldn't be acceptable. */ - limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); - if (limbo_entry == NULL) + txn->limbo_entry = txn_limbo_append(&txn_limbo, origin_id, txn); + if (txn->limbo_entry == NULL) goto rollback; } fiber_set_txn(fiber(), NULL); if (journal_write(req) != 0 || req->res < 0) { if (is_sync) - txn_limbo_abort(&txn_limbo, limbo_entry); + txn_limbo_abort(&txn_limbo, txn->limbo_entry); diag_set(ClientError, ER_WAL_IO); diag_log(); goto rollback; @@ -914,12 +911,12 @@ txn_commit(struct txn *txn) * blocking commit is used by local * transactions only. */ - txn_limbo_assign_local_lsn(&txn_limbo, limbo_entry, + txn_limbo_assign_local_lsn(&txn_limbo, txn->limbo_entry, lsn); /* Local WAL write is a first 'ACK'. */ txn_limbo_ack(&txn_limbo, txn_limbo.owner_id, lsn); } - if (txn_limbo_wait_complete(&txn_limbo, limbo_entry) < 0) + if (txn_limbo_wait_complete(&txn_limbo, txn->limbo_entry) < 0) goto rollback; } assert(txn_has_flag(txn, TXN_IS_DONE)); diff --git a/src/box/txn.h b/src/box/txn.h index a06aaea23..6b16372f4 100644 --- a/src/box/txn.h +++ b/src/box/txn.h @@ -349,6 +349,8 @@ struct txn { void *engine_tx; /* A fiber to wake up when transaction is finished. */ struct fiber *fiber; + /** A limbo entry associated with this transaction, if any. */ + struct txn_limbo_entry *limbo_entry; /** Timestampt of entry write start. */ double start_tm; /** -- 2.30.1 (Apple Git-130)