Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: tarantool-patches@freelists.org
Subject: Re: [PATCH 10/13] wal: make wal_sync fail on write error
Date: Wed, 14 Aug 2019 19:48:59 +0300	[thread overview]
Message-ID: <20190814164859.GO13834@esperanza> (raw)
In-Reply-To: <e0c09f403887269fd5aa1b3038c1e3de20fe20ec.1565430177.git.vdavydov.dev@gmail.com>

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()

  parent reply	other threads:[~2019-08-14 16:48 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10 10:03 [PATCH 00/13] Join replicas off the current read view Vladimir Davydov
2019-08-10 10:03 ` [PATCH 01/13] vinyl: embed engine in vy_env Vladimir Davydov
2019-08-12 22:14   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:09   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 02/13] vinyl: embed index in vy_lsm Vladimir Davydov
2019-08-12 22:14   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:09   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 03/13] vinyl: move reference counting from vy_lsm to index Vladimir Davydov
2019-08-12 22:16   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:09   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 04/13] vinyl: don't pin index for iterator lifetime Vladimir Davydov
2019-08-10 10:03 ` [PATCH 05/13] vinyl: don't exempt dropped indexes from dump and compaction Vladimir Davydov
2019-08-10 10:03 ` [PATCH 06/13] memtx: don't store pointers to index internals in iterator Vladimir Davydov
2019-08-12 22:21   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:10   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 07/13] memtx: use ref counting to pin indexes for snapshot Vladimir Davydov
2019-08-12 22:24   ` [tarantool-patches] " Konstantin Osipov
2019-08-13 10:56     ` Vladimir Davydov
2019-08-13 16:08       ` Georgy Kirichenko
2019-08-10 10:03 ` [PATCH 08/13] memtx: allow snapshot iterator to fail Vladimir Davydov
2019-08-12 22:25   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:10   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 09/13] memtx: enter small delayed free mode from snapshot iterator Vladimir Davydov
2019-08-12 22:27   ` [tarantool-patches] " Konstantin Osipov
2019-08-13 10:59     ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 10/13] wal: make wal_sync fail on write error Vladimir Davydov
2019-08-12 22:29   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 16:48   ` Vladimir Davydov [this message]
2019-08-10 10:03 ` [PATCH 11/13] xrow: factor out helper for setting REPLACE request body Vladimir Davydov
2019-08-12 22:29   ` [tarantool-patches] " Konstantin Osipov
2019-08-14 13:11   ` Vladimir Davydov
2019-08-10 10:03 ` [PATCH 12/13] test: disable replication/on_schema_init Vladimir Davydov
2019-08-12 22:31   ` [tarantool-patches] " Konstantin Osipov
2019-08-10 10:03 ` [PATCH 13/13] relay: join new replicas off read view 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=20190814164859.GO13834@esperanza \
    --to=vdavydov.dev@gmail.com \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH 10/13] wal: make wal_sync fail on write error' \
    /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