From: Vladimir Davydov <vdavydov.dev@gmail.com> To: kostja@tarantool.org Cc: georgy@tarantool.org, tarantool-patches@freelists.org Subject: [PATCH 2/4] vinyl: add tx to writers list in begin_statement engine callback Date: Mon, 4 Mar 2019 18:39:25 +0300 [thread overview] Message-ID: <bc9d2b08d3b9c38ba2bba76892b95082d609ce52.1551713282.git.vdavydov.dev@gmail.com> (raw) In-Reply-To: <cover.1551713282.git.vdavydov.dev@gmail.com> In-Reply-To: <cover.1551713282.git.vdavydov.dev@gmail.com> Currently, we add a transaction to the list of writers when executing a DML request, i.e. in vy_tx_set. The problem is a transaction can yield on read before calling vy_tx_set, e.g. to check a uniqueness constraint, which opens a time window when a transaction is not yet on the list, but it will surely proceed to DML after it continues execution. If we need to abort writers in this time window, we'll miss it. To prevent this, let's add a transaction to the list of writers in vy_tx_begin_statement. Note, after this patch, when a transaction is aborted for DDL, it may have an empty write set - it happens if tx_manager_abort_writers is called between vy_tx_begin_statement and vy_tx_set. Hence we have to remove the corresponding assertion from tx_manager_abort_writers. Needed for #4016 --- src/box/vy_tx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index 53c495d4..d216c73d 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -837,6 +837,8 @@ void * vy_tx_begin_statement(struct vy_tx *tx) { assert(tx->state == VINYL_TX_READY); + if (stailq_empty(&tx->log)) + rlist_add_entry(&tx->xm->writers, tx, in_writers); return stailq_last(&tx->log); } @@ -1057,8 +1059,6 @@ vy_tx_set_with_colmask(struct vy_tx *tx, struct vy_lsm *lsm, tx->write_set_version++; tx->write_size += tuple_size(stmt); vy_stmt_counter_acct_tuple(&lsm->stat.txw.count, stmt); - if (stailq_empty(&tx->log)) - rlist_add_entry(&tx->xm->writers, tx, in_writers); stailq_add_tail_entry(&tx->log, v, next_in_log); return 0; } @@ -1068,7 +1068,6 @@ tx_manager_abort_writers(struct tx_manager *xm, struct vy_lsm *lsm) { struct vy_tx *tx; rlist_foreach_entry(tx, &xm->writers, in_writers) { - assert(!vy_tx_is_ro(tx)); if (tx->state == VINYL_TX_READY && write_set_search_key(&tx->write_set, lsm, lsm->env->empty_key) != NULL) -- 2.11.0
next prev parent reply other threads:[~2019-03-04 15:39 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-03-04 15:39 [PATCH 0/4] Abort vinyl transactions before switching to ro Vladimir Davydov 2019-03-04 15:39 ` [PATCH 1/4] vinyl: rename tx statement begin/rollback routines Vladimir Davydov 2019-03-05 7:29 ` Konstantin Osipov 2019-03-04 15:39 ` Vladimir Davydov [this message] 2019-03-05 7:30 ` [PATCH 2/4] vinyl: add tx to writers list in begin_statement engine callback Konstantin Osipov 2019-03-04 15:39 ` [PATCH 3/4] engine: add switch_to_ro callback Vladimir Davydov 2019-03-05 7:31 ` Konstantin Osipov 2019-03-04 15:39 ` [PATCH 4/4] vinyl: abort rw transactions when instance switches to ro Vladimir Davydov 2019-03-05 7:43 ` Konstantin Osipov 2019-03-05 8:35 ` Vladimir Davydov
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bc9d2b08d3b9c38ba2bba76892b95082d609ce52.1551713282.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=georgy@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH 2/4] vinyl: add tx to writers list in begin_statement engine callback' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox