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 23FEA6EC40; Sun, 8 Aug 2021 17:35:38 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 23FEA6EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1628433338; bh=HdaG1BFw2OldUOK0tOGaFA2zZiJLcEZ8lDc9eB5Mwow=; h=To:References:Date:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=JKJALV9uKc0xIOrq8rx9nlOJ6q70xOCaWA5Nu/fR7zTG5rQHbPU//qLoEyNjoZrRm 4G5MTaOplMiC8YsePBm9VFq+b9iIYzd/6DdeNhOCoXSV3G289Fj9dCPuKgl+IMWwUs r/5cP8UROJAT/guH5Z9hxH1IPbNcEjYgTNOpDvu0= Received: from smtp46.i.mail.ru (smtp46.i.mail.ru [94.100.177.106]) (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 A33906EC40 for ; Sun, 8 Aug 2021 17:34:55 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A33906EC40 Received: by smtp46.i.mail.ru with esmtpa (envelope-from ) id 1mCjt9-0004ua-2b; Sun, 08 Aug 2021 17:34:55 +0300 To: Cyrill Gorcunov References: <20210804190752.488147-1-gorcunov@gmail.com> <20210804190752.488147-3-gorcunov@gmail.com> Message-ID: Date: Sun, 8 Aug 2021 17:34:54 +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: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD94BB7C0677F3ED9D05EB08EAFC9298EA6182A05F538085040939020ABAE335A714DAAD495A47075D5F592D583D784E706FF5D9A324687C940 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7F68DA2F3749BB650EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372FCE560095E3DFB88638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8E2CD9B73C4A2E2DD182E4AE4381D8372117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC6FC43C45D3E35E8FA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F4460429728776938767073520CCD848CCB6FE560C618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE41BF15D38FB6CB3A32F3B5D5B27460C0D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE37812A6222701F215302FCEF25BFAB345C4224003CC836476EA7A3FFF5B025636E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637BBEA499411984DA1EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5278E2403AABF0CD16E6C73B71642E0ED2492A669239841FFD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA75AF0B556A5A327A45410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3419891600CCEF46071F4D90D731F85918AB38BA8941A8BB90E08157AC3E092708F33649A4DADBADCE1D7E09C32AA3244C2274CF68739E3E8E8900FAC7E19DAB645A1673A01BA68E40FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMTMPlNJj3SjgEO+QKQGdFg== X-Mailru-Sender: 6C3E74F07C41AE94D32402E5012278FAC4DACE5771FC41C374AC6D053428AC5B16E256B11BC4C1E907784C02288277CA03E0582D3806FB6A5317862B1921BA260ED6CFD6382C13A6112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH v10 2/4] limbo: order access to the limbo terms 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 Cc: tml Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" On 06.08.2021 18:20, Cyrill Gorcunov wrote: > On Fri, Aug 06, 2021 at 01:29:57AM +0200, Vladislav Shpilevoy wrote: >>> apply_synchro_row(uint32_t replica_id, struct xrow_header *row) >>> { >>> assert(iproto_type_is_synchro_request(row->type)); >>> + int rc = 0; >>> >>> struct synchro_request req; >>> if (xrow_decode_synchro(row, &req) != 0) >>> goto err; >>> >>> + txn_limbo_term_lock(&txn_limbo); >> >> Maybe you should hide the lock from the API. Instead, do similar to >> what transactions do: >> >> int txn_limbo_process_begin(limbo *); >> void txn_limbo_process_commit(limbo *, request *); >> void txn_limbo_process_rollback(limbo *); >> >> begin would take the lock, commit would do the request and >> unlock, rollback would only unlock. Commit and rollback you >> call from apply_synchro_row_cb depend in on the WAL write >> result. >> >> Then the locks would disappear from the API, right? > > Unfortunatelly locking is needed not only for processing but > for reading terms as well. We have a few helpers more which > are waiting the other fibers to complete before reading terms. > > applier_apply_tx > applier_synchro_filter_tx > txn_limbo_is_replica_outdated > txn_limbo_term_lock > txn_limbo_replica_term_locked > txn_limbo_term_unlock > > And a number of calls for txn_limbo_replica_term which reads > term in a locked way because we need to eliminate potential > race here and fetch only last written data. > > So no, locking won't disappear. Another option may be to > introduce preemption disabling (just like kernel does for > tasks which should not be rescheduled on a core while > they are wating for some action to complete). Then our > write for synchro packets would look like > > preempt_disable(); > rc = journal_write(); > preempt_enable(); > > which would guarantee us that while we're waiting the journal > to finish its write no other fibers from the cord will be > executed and we gotta be woken up once write is complete. > > This way I think we will be allowed to drop locking at all > because main problem is exactly because of other fibers get > running while we're writing synchro data. > >> In the next patch you would make txn_limbo_process_begin() >> also take the request to validate it. Then the 'filtering' >> would become internal to the limbo. I didn't propose to drop the locking. I said it could be hidden inside of the limbo's API. In the only example above you show: > txn_limbo_term_lock > txn_limbo_replica_term_locked > txn_limbo_term_unlock Here the lock is done inside of the limbo's API too. It is not exposed on the limbo's API level. So the questions is the same - can it be hidden inside of the API? Are there any usages of the lock done explicitly out of the limo?