From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Wed, 14 Aug 2019 19:48:59 +0300 From: Vladimir Davydov Subject: Re: [PATCH 10/13] wal: make wal_sync fail on write error Message-ID: <20190814164859.GO13834@esperanza> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: To: tarantool-patches@freelists.org List-ID: Pushed to master after adding a test case: diff --git a/src/box/wal.c b/src/box/wal.c index 267cafed..9219d677 100644 --- a/src/box/wal.c +++ b/src/box/wal.c @@ -540,6 +540,11 @@ wal_sync_f(struct cbus_call_msg *msg) int wal_sync(void) { + ERROR_INJECT(ERRINJ_WAL_SYNC, { + diag_set(ClientError, ER_INJECTION, "wal sync"); + return -1; + }); + struct wal_writer *writer = &wal_writer_singleton; if (writer->wal_mode == WAL_NONE) return 0; diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h index fe9c2237..e75a620d 100644 --- a/src/lib/core/errinj.h +++ b/src/lib/core/errinj.h @@ -73,6 +73,7 @@ struct errinj { #define ERRINJ_LIST(_) \ _(ERRINJ_TESTING, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_WAL_IO, ERRINJ_BOOL, {.bparam = false}) \ + _(ERRINJ_WAL_SYNC, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_WAL_ROTATE, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_WAL_WRITE, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_WAL_WRITE_PARTIAL, ERRINJ_INT, {.iparam = -1}) \ diff --git a/test/box/errinj.result b/test/box/errinj.result index af2f8877..5784758d 100644 --- a/test/box/errinj.result +++ b/test/box/errinj.result @@ -20,25 +20,27 @@ errinj.info() state: false ERRINJ_VYRUN_DATA_READ: state: false + ERRINJ_SWIM_FD_ONLY: + state: false ERRINJ_SQL_NAME_NORMALIZATION: state: false ERRINJ_VY_SCHED_TIMEOUT: state: 0 - ERRINJ_SWIM_FD_ONLY: - state: false ERRINJ_COIO_SENDFILE_CHUNK: state: -1 + ERRINJ_VY_LOG_FILE_RENAME: + state: false ERRINJ_WAL_WRITE_PARTIAL: state: -1 ERRINJ_VY_GC: state: false ERRINJ_WAL_DELAY: state: false - ERRINJ_VY_INDEX_DUMP: - state: -1 + ERRINJ_INDEX_ALLOC: + state: false ERRINJ_WAL_WRITE_EOF: state: false - ERRINJ_VY_LOG_FILE_RENAME: + ERRINJ_WAL_SYNC: state: false ERRINJ_VYRUN_INDEX_GARBAGE: state: false @@ -122,20 +124,20 @@ errinj.info() state: false ERRINJ_XLOG_GARBAGE: state: false - ERRINJ_INDEX_ALLOC: - state: false + ERRINJ_VY_INDEX_DUMP: + state: -1 ERRINJ_VY_READ_PAGE_DELAY: state: false ERRINJ_TESTING: state: false - ERRINJ_RELAY_TIMEOUT: - state: 0 + ERRINJ_RELAY_SEND_DELAY: + state: false ERRINJ_VY_SQUASH_TIMEOUT: state: 0 ERRINJ_VY_LOG_FLUSH: state: false - ERRINJ_RELAY_SEND_DELAY: - state: false + ERRINJ_RELAY_TIMEOUT: + state: 0 ... errinj.set("some-injection", true) --- diff --git a/test/vinyl/errinj_ddl.result b/test/vinyl/errinj_ddl.result index 8fe9064b..deebda89 100644 --- a/test/vinyl/errinj_ddl.result +++ b/test/vinyl/errinj_ddl.result @@ -689,3 +689,59 @@ test_run:cmd("setopt delimiter ''"); box.cfg{vinyl_cache = default_vinyl_cache} --- ... +-- +-- Check that DDL fails if it fails to flush pending WAL writes. +-- Done in the scope of gh-1271. +-- +s = box.schema.space.create('test', {engine = 'vinyl'}) +--- +... +_ = s:create_index('primary') +--- +... +s:replace{1, 2} +--- +- [1, 2] +... +box.error.injection.set('ERRINJ_WAL_SYNC', true) +--- +- ok +... +s:format({{'a', 'unsigned'}, {'b', 'unsigned'}}) -- ok +--- +... +_ = s:create_index('secondary', {parts = {2, 'unsigned'}}) -- ok +--- +... +s:format({}) +--- +... +s.index.secondary:drop() +--- +... +box.error.injection.set('ERRINJ_WAL_DELAY', true) +--- +- ok +... +_ = fiber.create(function() s:replace{3, 4} end) +--- +... +s:format({{'a', 'unsigned'}, {'b', 'unsigned'}}) -- error +--- +- error: Error injection 'wal sync' +... +_ = s:create_index('secondary', {parts = {2, 'unsigned'}}) -- error +--- +- error: Error injection 'wal sync' +... +box.error.injection.set('ERRINJ_WAL_DELAY', false) +--- +- ok +... +box.error.injection.set('ERRINJ_WAL_SYNC', false) +--- +- ok +... +s:drop() +--- +... diff --git a/test/vinyl/errinj_ddl.test.lua b/test/vinyl/errinj_ddl.test.lua index 3bc8bed8..9039d357 100644 --- a/test/vinyl/errinj_ddl.test.lua +++ b/test/vinyl/errinj_ddl.test.lua @@ -300,3 +300,29 @@ box.error.injection.set('ERRINJ_VY_READ_PAGE_TIMEOUT', 0); test_run:cmd("setopt delimiter ''"); box.cfg{vinyl_cache = default_vinyl_cache} + +-- +-- Check that DDL fails if it fails to flush pending WAL writes. +-- Done in the scope of gh-1271. +-- +s = box.schema.space.create('test', {engine = 'vinyl'}) +_ = s:create_index('primary') +s:replace{1, 2} + +box.error.injection.set('ERRINJ_WAL_SYNC', true) + +s:format({{'a', 'unsigned'}, {'b', 'unsigned'}}) -- ok +_ = s:create_index('secondary', {parts = {2, 'unsigned'}}) -- ok + +s:format({}) +s.index.secondary:drop() + +box.error.injection.set('ERRINJ_WAL_DELAY', true) +_ = fiber.create(function() s:replace{3, 4} end) + +s:format({{'a', 'unsigned'}, {'b', 'unsigned'}}) -- error +_ = s:create_index('secondary', {parts = {2, 'unsigned'}}) -- error + +box.error.injection.set('ERRINJ_WAL_DELAY', false) +box.error.injection.set('ERRINJ_WAL_SYNC', false) +s:drop()