From: Aleksandr Lyapunov <alyapunov@tarantool.org> To: tarantool-patches@dev.tarantool.org Subject: [Tarantool-patches] [PATCH v4 01/12] vinyl: rename tx_manager -> vy_tx_manager Date: Tue, 8 Sep 2020 13:22:01 +0300 [thread overview] Message-ID: <1599560532-27089-2-git-send-email-alyapunov@tarantool.org> (raw) In-Reply-To: <1599560532-27089-1-git-send-email-alyapunov@tarantool.org> Apart from other vinyl objects that are named with "vy_" prefix, its transaction manager (tx_manager) have no such prefix. It should have in order to avoid conflicts with global tx manager. Needed for #4897 --- src/box/vinyl.c | 30 ++++++++++++++--------------- src/box/vy_scheduler.h | 2 +- src/box/vy_tx.c | 51 +++++++++++++++++++++++++------------------------- src/box/vy_tx.h | 33 ++++++++++++++++---------------- 4 files changed, 59 insertions(+), 57 deletions(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 5fa3ea3..aa6e50f 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -98,7 +98,7 @@ struct vy_env { /** Recovery status */ enum vy_status status; /** TX manager */ - struct tx_manager *xm; + struct vy_tx_manager *xm; /** Upsert squash queue */ struct vy_squash_queue *squash_queue; /** Memory pool for index iterator. */ @@ -267,7 +267,7 @@ vy_info_append_regulator(struct vy_env *env, struct info_handler *h) static void vy_info_append_tx(struct vy_env *env, struct info_handler *h) { - struct tx_manager *xm = env->xm; + struct vy_tx_manager *xm = env->xm; info_table_begin(h, "tx"); @@ -292,7 +292,7 @@ static void vy_info_append_memory(struct vy_env *env, struct info_handler *h) { info_table_begin(h, "memory"); - info_append_int(h, "tx", tx_manager_mem_used(env->xm)); + info_append_int(h, "tx", vy_tx_manager_mem_used(env->xm)); info_append_int(h, "level0", lsregion_used(&env->mem_env.allocator)); info_append_int(h, "tuple_cache", env->cache_env.mem_used); info_append_int(h, "page_index", env->lsm_env.page_index_size); @@ -509,7 +509,7 @@ vinyl_engine_memory_stat(struct engine *engine, struct engine_memory_stat *stat) stat->index += env->lsm_env.bloom_size; stat->index += env->lsm_env.page_index_size; stat->cache += env->cache_env.mem_used; - stat->tx += tx_manager_mem_used(env->xm); + stat->tx += vy_tx_manager_mem_used(env->xm); } static void @@ -517,7 +517,7 @@ vinyl_engine_reset_stat(struct engine *engine) { struct vy_env *env = vy_env(engine); - struct tx_manager *xm = env->xm; + struct vy_tx_manager *xm = env->xm; memset(&xm->stat, 0, sizeof(xm->stat)); vy_scheduler_reset_stat(&env->scheduler); @@ -999,7 +999,7 @@ vinyl_space_invalidate(struct space *space) * request bail out early, without dereferencing the space. */ bool unused; - tx_manager_abort_writers_for_ddl(env->xm, space, &unused); + vy_tx_manager_abort_writers_for_ddl(env->xm, space, &unused); } /** Argument passed to vy_check_format_on_replace(). */ @@ -1067,7 +1067,7 @@ vinyl_space_check_format(struct space *space, struct tuple_format *format) * be checked with on_replace trigger so we abort them. */ bool need_wal_sync; - tx_manager_abort_writers_for_ddl(env->xm, space, &need_wal_sync); + vy_tx_manager_abort_writers_for_ddl(env->xm, space, &need_wal_sync); if (!need_wal_sync && vy_lsm_is_empty(pk)) return 0; /* space is empty, nothing to do */ @@ -2489,7 +2489,7 @@ static void vinyl_engine_switch_to_ro(struct engine *engine) { struct vy_env *env = vy_env(engine); - tx_manager_abort_writers_for_ro(env->xm); + vy_tx_manager_abort_writers_for_ro(env->xm); } /* }}} Public API of transaction control */ @@ -2576,7 +2576,7 @@ vy_env_new(const char *path, size_t memory, goto error_path; } - e->xm = tx_manager_new(); + e->xm = vy_tx_manager_new(); if (e->xm == NULL) goto error_xm; e->squash_queue = vy_squash_queue_new(); @@ -2612,7 +2612,7 @@ error_lsm_env: vy_scheduler_destroy(&e->scheduler); vy_squash_queue_delete(e->squash_queue); error_squash_queue: - tx_manager_delete(e->xm); + vy_tx_manager_delete(e->xm); error_xm: free(e->path); error_path: @@ -2626,7 +2626,7 @@ vy_env_delete(struct vy_env *e) vy_regulator_destroy(&e->regulator); vy_scheduler_destroy(&e->scheduler); vy_squash_queue_delete(e->squash_queue); - tx_manager_delete(e->xm); + vy_tx_manager_delete(e->xm); free(e->path); mempool_destroy(&e->iterator_pool); vy_run_env_destroy(&e->run_env); @@ -2885,7 +2885,7 @@ vinyl_engine_end_recovery(struct engine *engine) /* * During recovery we skip statements that have * been dumped to disk - see vy_is_committed() - - * so it may turn out that tx_manager::lsn stays + * so it may turn out that vy_tx_manager::lsn stays * behind the instance vclock while we need it * to be up-to-date once recovery is complete, * because we use it while building an index to @@ -3709,7 +3709,7 @@ vinyl_snapshot_iterator_free(struct snapshot_iterator *base) struct vy_lsm *lsm = it->iterator.lsm; struct vy_env *env = vy_env(lsm->base.engine); vy_read_iterator_close(&it->iterator); - tx_manager_destroy_read_view(env->xm, it->rv); + vy_tx_manager_destroy_read_view(env->xm, it->rv); vy_lsm_unref(lsm); free(it); } @@ -3729,7 +3729,7 @@ vinyl_index_create_snapshot_iterator(struct index *base) it->base.next = vinyl_snapshot_iterator_next; it->base.free = vinyl_snapshot_iterator_free; - it->rv = tx_manager_read_view(env->xm); + it->rv = vy_tx_manager_read_view(env->xm); if (it->rv == NULL) { free(it); return NULL; @@ -4152,7 +4152,7 @@ vinyl_space_build_index(struct space *src_space, struct index *new_index, * be checked with on_replace trigger so we abort them. */ bool need_wal_sync; - tx_manager_abort_writers_for_ddl(env->xm, src_space, &need_wal_sync); + vy_tx_manager_abort_writers_for_ddl(env->xm, src_space, &need_wal_sync); if (!need_wal_sync && vy_lsm_is_empty(pk)) return 0; /* space is empty, nothing to do */ diff --git a/src/box/vy_scheduler.h b/src/box/vy_scheduler.h index 42e7b2f..f487b42 100644 --- a/src/box/vy_scheduler.h +++ b/src/box/vy_scheduler.h @@ -148,7 +148,7 @@ struct vy_scheduler { * by the dump. */ vy_scheduler_dump_complete_f dump_complete_cb; - /** List of read views, see tx_manager::read_views. */ + /** List of read views, see vy_tx_manager::read_views. */ struct rlist *read_views; /** Context needed for writing runs. */ struct vy_run_env *run_env; diff --git a/src/box/vy_tx.c b/src/box/vy_tx.c index 846c632..ff63cd7 100644 --- a/src/box/vy_tx.c +++ b/src/box/vy_tx.c @@ -98,13 +98,13 @@ vy_global_read_view_create(struct vy_read_view *rv, int64_t lsn) rv->refs = 0; } -struct tx_manager * -tx_manager_new(void) +struct vy_tx_manager * +vy_tx_manager_new(void) { - struct tx_manager *xm = calloc(1, sizeof(*xm)); + struct vy_tx_manager *xm = calloc(1, sizeof(*xm)); if (xm == NULL) { diag_set(OutOfMemory, sizeof(*xm), - "malloc", "struct tx_manager"); + "malloc", "struct vy_tx_manager"); return NULL; } @@ -128,7 +128,7 @@ tx_manager_new(void) } void -tx_manager_delete(struct tx_manager *xm) +vy_tx_manager_delete(struct vy_tx_manager *xm) { mempool_destroy(&xm->read_view_mempool); mempool_destroy(&xm->read_interval_mempool); @@ -138,7 +138,7 @@ tx_manager_delete(struct tx_manager *xm) } size_t -tx_manager_mem_used(struct tx_manager *xm) +vy_tx_manager_mem_used(struct vy_tx_manager *xm) { struct mempool_stats mstats; size_t ret = 0; @@ -157,7 +157,7 @@ tx_manager_mem_used(struct tx_manager *xm) } struct vy_read_view * -tx_manager_read_view(struct tx_manager *xm) +vy_tx_manager_read_view(struct vy_tx_manager *xm) { struct vy_read_view *rv; /* @@ -195,7 +195,8 @@ tx_manager_read_view(struct tx_manager *xm) } void -tx_manager_destroy_read_view(struct tx_manager *xm, struct vy_read_view *rv) +vy_tx_manager_destroy_read_view(struct vy_tx_manager *xm, + struct vy_read_view *rv) { if (rv == xm->p_global_read_view) return; @@ -209,7 +210,7 @@ tx_manager_destroy_read_view(struct tx_manager *xm, struct vy_read_view *rv) static struct txv * txv_new(struct vy_tx *tx, struct vy_lsm *lsm, struct vy_entry entry) { - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; struct txv *v = mempool_alloc(&xm->txv_mempool); if (v == NULL) { diag_set(OutOfMemory, sizeof(*v), "mempool", "struct txv"); @@ -234,7 +235,7 @@ txv_new(struct vy_tx *tx, struct vy_lsm *lsm, struct vy_entry entry) static void txv_delete(struct txv *v) { - struct tx_manager *xm = v->tx->xm; + struct vy_tx_manager *xm = v->tx->xm; xm->write_set_size -= tuple_size(v->entry.stmt); vy_stmt_counter_unacct_tuple(&v->lsm->stat.txw.count, v->entry.stmt); tuple_unref(v->entry.stmt); @@ -248,7 +249,7 @@ txv_delete(struct txv *v) static void vy_read_interval_acct(struct vy_read_interval *interval) { - struct tx_manager *xm = interval->tx->xm; + struct vy_tx_manager *xm = interval->tx->xm; xm->read_set_size += tuple_size(interval->left.stmt); if (interval->left.stmt != interval->right.stmt) xm->read_set_size += tuple_size(interval->right.stmt); @@ -260,7 +261,7 @@ vy_read_interval_acct(struct vy_read_interval *interval) static void vy_read_interval_unacct(struct vy_read_interval *interval) { - struct tx_manager *xm = interval->tx->xm; + struct vy_tx_manager *xm = interval->tx->xm; xm->read_set_size -= tuple_size(interval->left.stmt); if (interval->left.stmt != interval->right.stmt) xm->read_set_size -= tuple_size(interval->right.stmt); @@ -271,7 +272,7 @@ vy_read_interval_new(struct vy_tx *tx, struct vy_lsm *lsm, struct vy_entry left, bool left_belongs, struct vy_entry right, bool right_belongs) { - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; struct vy_read_interval *interval; interval = mempool_alloc(&xm->read_interval_mempool); if (interval == NULL) { @@ -296,7 +297,7 @@ vy_read_interval_new(struct vy_tx *tx, struct vy_lsm *lsm, static void vy_read_interval_delete(struct vy_read_interval *interval) { - struct tx_manager *xm = interval->tx->xm; + struct vy_tx_manager *xm = interval->tx->xm; vy_read_interval_unacct(interval); vy_lsm_unref(interval->lsm); tuple_unref(interval->left.stmt); @@ -316,7 +317,7 @@ vy_tx_read_set_free_cb(vy_tx_read_set_t *read_set, } void -vy_tx_create(struct tx_manager *xm, struct vy_tx *tx) +vy_tx_create(struct vy_tx_manager *xm, struct vy_tx *tx) { tx->last_stmt_space = NULL; stailq_create(&tx->log); @@ -339,7 +340,7 @@ vy_tx_destroy(struct vy_tx *tx) trigger_run(&tx->on_destroy, NULL); trigger_destroy(&tx->on_destroy); - tx_manager_destroy_read_view(tx->xm, tx->read_view); + vy_tx_manager_destroy_read_view(tx->xm, tx->read_view); struct txv *v, *tmp; stailq_foreach_entry_safe(v, tmp, &tx->log, next_in_log) @@ -392,7 +393,7 @@ vy_tx_send_to_read_view(struct vy_tx *tx, struct txv *v) /* already in (earlier) read view */ if (vy_tx_is_in_read_view(abort)) continue; - struct vy_read_view *rv = tx_manager_read_view(tx->xm); + struct vy_read_view *rv = vy_tx_manager_read_view(tx->xm); if (rv == NULL) return -1; abort->read_view = rv; @@ -422,7 +423,7 @@ vy_tx_abort_readers(struct vy_tx *tx, struct txv *v) } struct vy_tx * -vy_tx_begin(struct tx_manager *xm) +vy_tx_begin(struct vy_tx_manager *xm) { struct vy_tx *tx = mempool_alloc(&xm->tx_mempool); if (unlikely(tx == NULL)) { @@ -662,7 +663,7 @@ vy_tx_handle_deferred_delete(struct vy_tx *tx, struct txv *v) int vy_tx_prepare(struct vy_tx *tx) { - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; if (tx->state == VINYL_TX_ABORT) { /* Conflict is already accounted - see vy_tx_abort(). */ @@ -793,7 +794,7 @@ void vy_tx_commit(struct vy_tx *tx, int64_t lsn) { assert(tx->state == VINYL_TX_COMMIT); - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; xm->stat.commit++; @@ -833,7 +834,7 @@ vy_tx_rollback_after_prepare(struct vy_tx *tx) { assert(tx->state == VINYL_TX_COMMIT); - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; /* * There are two reasons of rollback_after_prepare: @@ -878,7 +879,7 @@ vy_tx_rollback_after_prepare(struct vy_tx *tx) void vy_tx_rollback(struct vy_tx *tx) { - struct tx_manager *xm = tx->xm; + struct vy_tx_manager *xm = tx->xm; xm->stat.rollback++; @@ -1140,8 +1141,8 @@ vy_tx_set(struct vy_tx *tx, struct vy_lsm *lsm, struct tuple *stmt) } void -tx_manager_abort_writers_for_ddl(struct tx_manager *xm, struct space *space, - bool *need_wal_sync) +vy_tx_manager_abort_writers_for_ddl(struct vy_tx_manager *xm, + struct space *space, bool *need_wal_sync) { *need_wal_sync = false; if (space->index_count == 0) @@ -1166,7 +1167,7 @@ tx_manager_abort_writers_for_ddl(struct tx_manager *xm, struct space *space, } void -tx_manager_abort_writers_for_ro(struct tx_manager *xm) +vy_tx_manager_abort_writers_for_ro(struct vy_tx_manager *xm) { struct vy_tx *tx; rlist_foreach_entry(tx, &xm->writers, in_writers) { diff --git a/src/box/vy_tx.h b/src/box/vy_tx.h index 3144c92..4fac5f6 100644 --- a/src/box/vy_tx.h +++ b/src/box/vy_tx.h @@ -54,7 +54,7 @@ extern "C" { struct space; struct tuple; -struct tx_manager; +struct vy_tx_manager; struct vy_mem; struct vy_tx; struct vy_history; @@ -140,16 +140,16 @@ write_set_search_key(write_set_t *tree, struct vy_lsm *lsm, /** Transaction object. */ struct vy_tx { - /** Link in tx_manager::writers. */ + /** Link in vy_tx_manager::writers. */ struct rlist in_writers; /** Transaction manager. */ - struct tx_manager *xm; + struct vy_tx_manager *xm; /** * Pointer to the space affected by the last prepared statement. * We need it so that we can abort a transaction on DDL even * if it hasn't inserted anything into the write set yet (e.g. * yielded on unique check) and therefore would otherwise be - * ignored by tx_manager_abort_writers_for_ddl(). + * ignored by vy_tx_manager_abort_writers_for_ddl(). */ struct space *last_stmt_space; /** @@ -209,7 +209,7 @@ vy_tx_read_view(struct vy_tx *tx) } /** Transaction manager object. */ -struct tx_manager { +struct vy_tx_manager { /** * The last committed log sequence number known to * vinyl. Updated in vy_commit(). @@ -278,24 +278,25 @@ struct tx_manager { }; /** Allocate a tx manager object. */ -struct tx_manager * -tx_manager_new(void); +struct vy_tx_manager * +vy_tx_manager_new(void); /** Delete a tx manager object. */ void -tx_manager_delete(struct tx_manager *xm); +vy_tx_manager_delete(struct vy_tx_manager *xm); /** Return total amount of memory used by active transactions. */ size_t -tx_manager_mem_used(struct tx_manager *xm); +vy_tx_manager_mem_used(struct vy_tx_manager *xm); /** Create or reuse an instance of a read view. */ struct vy_read_view * -tx_manager_read_view(struct tx_manager *xm); +vy_tx_manager_read_view(struct vy_tx_manager *xm); /** Dereference and possibly destroy a read view. */ void -tx_manager_destroy_read_view(struct tx_manager *xm, struct vy_read_view *rv); +vy_tx_manager_destroy_read_view(struct vy_tx_manager *xm, + struct vy_read_view *rv); /** * Abort all rw transactions that affect the given space @@ -307,19 +308,19 @@ tx_manager_destroy_read_view(struct tx_manager *xm, struct vy_read_view *rv); * to call wal_sync() to flush them. */ void -tx_manager_abort_writers_for_ddl(struct tx_manager *xm, struct space *space, - bool *need_wal_sync); +vy_tx_manager_abort_writers_for_ddl(struct vy_tx_manager *xm, + struct space *space, bool *need_wal_sync); /** * Abort all local rw transactions that haven't reached WAL yet. * Called before switching to read-only mode. */ void -tx_manager_abort_writers_for_ro(struct tx_manager *xm); +vy_tx_manager_abort_writers_for_ro(struct vy_tx_manager *xm); /** Initialize a tx object. */ void -vy_tx_create(struct tx_manager *xm, struct vy_tx *tx); +vy_tx_create(struct vy_tx_manager *xm, struct vy_tx *tx); /** Destroy a tx object. */ void @@ -327,7 +328,7 @@ vy_tx_destroy(struct vy_tx *tx); /** Begin a new transaction. */ struct vy_tx * -vy_tx_begin(struct tx_manager *xm); +vy_tx_begin(struct vy_tx_manager *xm); /** Prepare a transaction to be committed. */ int -- 2.7.4
next prev parent reply other threads:[~2020-09-08 10:22 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-08 10:22 [Tarantool-patches] [PATCH v4 00/12] Transaction engine for memtx engine Aleksandr Lyapunov 2020-09-08 10:22 ` Aleksandr Lyapunov [this message] 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 02/12] txm: add TX status Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 03/12] txm: save does_require_old_tuple flag in txn_stmt Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 04/12] txm: introduce prepare sequence number Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 05/12] txm: introduce memtx tx manager Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 06/12] txm: introduce conflict tracker Aleksandr Lyapunov 2020-09-14 16:36 ` Nikita Pettik 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 07/12] txm: introduce memtx_story Aleksandr Lyapunov 2020-09-15 14:33 ` Nikita Pettik 2020-09-22 17:51 ` Aleksandr Lyapunov 2020-09-23 10:25 ` Nikita Pettik 2020-09-23 11:09 ` Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 08/12] txm: introduce snapshot cleaner Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 09/12] txm: clarify all fetched tuples Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 10/12] txm: use new tx manager in memtx Aleksandr Lyapunov 2020-09-15 17:59 ` Nikita Pettik 2020-09-22 17:53 ` Aleksandr Lyapunov 2020-09-23 10:26 ` Nikita Pettik 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 11/12] test: move txn_proxy.lua to box/lua Aleksandr Lyapunov 2020-09-08 10:22 ` [Tarantool-patches] [PATCH v4 12/12] txm: add a test Aleksandr Lyapunov 2020-09-15 18:05 ` Nikita Pettik 2020-09-22 17:58 ` Aleksandr Lyapunov 2020-09-23 11:07 ` Nikita Pettik 2020-09-23 11:12 ` Aleksandr Lyapunov 2020-09-23 12:18 ` [Tarantool-patches] [PATCH v4 00/12] Transaction engine for memtx engine Kirill Yukhin
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=1599560532-27089-2-git-send-email-alyapunov@tarantool.org \ --to=alyapunov@tarantool.org \ --cc=tarantool-patches@dev.tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH v4 01/12] vinyl: rename tx_manager -> vy_tx_manager' \ /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