From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH 0/6] Get rid of the schema lock Date: Sun, 30 Jun 2019 22:40:13 +0300 Message-Id: To: kostja@tarantool.org Cc: tarantool-patches@freelists.org List-ID: The schema lock was initially introduced to prevent a space from being dropped while the memtx checkpoint thread dumps its content to a snap file. Later on it was reused for syncing DDL-vs-DDL. Now we take it before any statement involving _space, _index, and _truncate spaces. This prevents us from batching several non-yielding DDL statements in the same transaction (see #4083). For instance, suppose we want to create a space and then an index for the space in the same transaction. Then we would deadlock while trying to take the schema lock before executing the second statement. We could, of course, make the lock reentrant, but that would rather look like a hack. Actually, we don't really need this lock for syncing checkpointing vs DDL - we can simply postpone index destruction until after checkpointing is complete. Moreover, all the necessary infrastructure has already been implemented in the scope of #3408 ("Free tuples on space drop/truncate in background fiber"). It also seems that we don't need this lock for syncing DDL vs DDL, either, since instead we can lock individual spaces. So this patch removes the schema lock altogether. This is a preparation for transaction DDL (see #4083). https://github.com/tarantool/tarantool/issues/4083 https://github.com/tarantool/tarantool/commits/dv/zap-schema-lock Vladimir Davydov (6): Add ERROR_INJECT_YIELD and ERROR_INJECT_SLEEP helpers Replace ERRINJ_SNAP_WRITE_ROW_TIMEOUT with ERRINJ_SNAP_WRITE_DELAY Don't take schema lock for checkpointing test: make vinyl/replica_rejoin more stable vinyl: don't yield while logging index creation Replace schema lock with fine-grained locking src/box/alter.cc | 68 +++-------------- src/box/alter.h | 3 - src/box/gc.c | 8 -- src/box/memtx_engine.c | 64 +++++++++------- src/box/memtx_engine.h | 5 ++ src/box/memtx_space.c | 79 +++++++------------ src/box/relay.cc | 6 +- src/box/schema.cc | 41 +++++----- src/box/schema.h | 6 -- src/box/space.c | 2 - src/box/space.h | 7 +- src/box/txn.c | 3 - src/box/vinyl.c | 23 +----- src/box/vy_log.c | 6 +- src/box/vy_lsm.c | 4 +- src/box/vy_run.c | 6 +- src/box/vy_scheduler.c | 22 ++---- src/box/wal.c | 4 +- src/curl.c | 7 +- src/lib/core/errinj.h | 12 ++- src/lib/core/latch.h | 10 --- test/app-tap/snapshot.test.lua | 5 +- test/box/errinj.result | 38 +++++----- test/box/errinj.test.lua | 6 +- test/box/on_replace.result | 8 +- test/box/transaction.result | 2 +- test/engine/errinj_ddl.result | 152 +++++++++++++++++++++++++++++++++++++ test/engine/errinj_ddl.test.lua | 62 +++++++++++++++ test/unit/vy_log_stub.c | 3 + test/vinyl/errinj_vylog.result | 23 +++++- test/vinyl/errinj_vylog.test.lua | 10 ++- test/vinyl/replica_rejoin.result | 119 ++++++++++++++--------------- test/vinyl/replica_rejoin.test.lua | 34 +++++---- test/xlog/errinj.result | 4 +- test/xlog/errinj.test.lua | 4 +- 35 files changed, 489 insertions(+), 367 deletions(-) -- 2.11.0