diff --git a/src/box/vy_run.c b/src/box/vy_run.c index ec2179bfbac9f7df955753b71b5ae7cacbab4e35..159e72b6a20bf775a06422a324943ce2352c07a1 100644 --- a/src/box/vy_run.c +++ b/src/box/vy_run.c @@ -1659,8 +1659,8 @@ vy_run_recover(struct vy_run *run, const char *dir, space_id, iid, run->id, VY_FILE_INDEX); struct xlog_cursor cursor; - ERROR_INJECT_COUNTDOWN(ERRINJ_VY_RUN_OPEN, { - diag_set(SystemError, "failed to open '%s' file", path); + ERROR_INJECT_COUNTDOWN(ERRINJ_VY_RUN_RECOVER_COUNTDOWN, { + diag_set(ClientError, ER_INJECTION, "vinyl run recover"); goto fail; }); if (xlog_cursor_open(&cursor, path)) diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index 40b9a4b0565c33a17f7541ac86fadde7176889c9..f4adf263bc3e60dc3e7f9ee918b2f0f2bd56a333 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -198,16 +198,11 @@ vy_stmt_alloc(struct tuple_format *format, uint32_t data_offset, uint32_t bsize) error_log(diag_last_error(diag_get())); return NULL; } -#ifndef NDEBUG - struct errinj *inj = errinj(ERRINJ_VY_STMT_ALLOC, ERRINJ_INT); - if (inj != NULL && inj->iparam >= 0) { - if (inj->iparam-- == 0) { - diag_set(OutOfMemory, total_size, "malloc", - "struct vy_stmt"); - return NULL; - } - } -#endif + ERROR_INJECT_COUNTDOWN(ERRINJ_VY_STMT_ALLOC_COUNTDOWN, { + diag_set(ClientError, ER_INJECTION, + "vinyl statement allocate"); + return NULL; + }); struct tuple *tuple = malloc(total_size); if (unlikely(tuple == NULL)) { diag_set(OutOfMemory, total_size, "malloc", "struct vy_stmt"); diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h index 88f394dd949d70ccd51b7d31ec74677f182f5e06..903de158a050f3e40a0113651baa282c141aa26f 100644 --- a/src/lib/core/errinj.h +++ b/src/lib/core/errinj.h @@ -165,13 +165,13 @@ struct errinj { _(ERRINJ_VY_READ_VIEW_MERGE_FAIL, ERRINJ_BOOL, {.bparam = false})\ _(ERRINJ_VY_RUN_DISCARD, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_VY_RUN_FILE_RENAME, ERRINJ_BOOL, {.bparam = false}) \ - _(ERRINJ_VY_RUN_OPEN, ERRINJ_INT, {.iparam = -1})\ + _(ERRINJ_VY_RUN_RECOVER_COUNTDOWN, ERRINJ_INT, {.iparam = -1})\ _(ERRINJ_VY_RUN_WRITE, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_VY_RUN_WRITE_DELAY, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_VY_RUN_WRITE_STMT_TIMEOUT, ERRINJ_DOUBLE, {.dparam = 0}) \ _(ERRINJ_VY_SCHED_TIMEOUT, ERRINJ_DOUBLE, {.dparam = 0}) \ _(ERRINJ_VY_SQUASH_TIMEOUT, ERRINJ_DOUBLE, {.dparam = 0}) \ - _(ERRINJ_VY_STMT_ALLOC, ERRINJ_INT, {.iparam = -1})\ + _(ERRINJ_VY_STMT_ALLOC_COUNTDOWN, ERRINJ_INT, {.iparam = -1})\ _(ERRINJ_VY_TASK_COMPLETE, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_VY_WRITE_ITERATOR_START_FAIL, ERRINJ_BOOL, {.bparam = false})\ _(ERRINJ_WAIT_QUORUM_COUNT, ERRINJ_INT, {.iparam = 0}) \ diff --git a/test/vinyl/errinj_recovery.lua b/test/vinyl/errinj_recovery.lua index eca6b9df232aa909b55ed3b7c9a8e068de3561fb..2c6de5a6d5aea15ad4dbd1021393e9c8ba0c1feb 100644 --- a/test/vinyl/errinj_recovery.lua +++ b/test/vinyl/errinj_recovery.lua @@ -1,7 +1,7 @@ #!/usr/bin/env tarantool -box.error.injection.set('ERRINJ_VY_RUN_OPEN', 2) -assert(box.error.injection.get('ERRINJ_VY_RUN_OPEN')) +box.error.injection.set('ERRINJ_VY_RUN_RECOVER_COUNTDOWN', 2) +assert(box.error.injection.get('ERRINJ_VY_RUN_RECOVER_COUNTDOWN')) box.cfg { listen = os.getenv("LISTEN"), diff --git a/test/vinyl/gh-4805-open-run-err-recovery.result b/test/vinyl/gh-4805-open-run-err-recovery.result index 6366dea91c3b1acfa46b2d33fddfb6ec9c7a71be..c3da9565ffbd2d5846704cfcf3e9eebbbbe6d3f9 100644 --- a/test/vinyl/gh-4805-open-run-err-recovery.result +++ b/test/vinyl/gh-4805-open-run-err-recovery.result @@ -76,7 +76,7 @@ opts = {} opts.filename = 'errinj_recovery.log' | --- | ... -test_run:grep_log('err_recovery', 'failed to open', 1000, opts) ~= nil +test_run:grep_log('err_recovery', "Error injection 'vinyl run recover'", 1000, opts) ~= nil | --- | - true | ... diff --git a/test/vinyl/gh-4805-open-run-err-recovery.test.lua b/test/vinyl/gh-4805-open-run-err-recovery.test.lua index 0b97f09da7a846dea9338698eb8b8f8121e862f3..689c5cb58d559689387a7ad0c84b73e8cd543093 100644 --- a/test/vinyl/gh-4805-open-run-err-recovery.test.lua +++ b/test/vinyl/gh-4805-open-run-err-recovery.test.lua @@ -29,6 +29,6 @@ test_run:cmd('start server err_recovery with crash_expected=True') opts = {} opts.filename = 'errinj_recovery.log' -test_run:grep_log('err_recovery', 'failed to open', 1000, opts) ~= nil +test_run:grep_log('err_recovery', "Error injection 'vinyl run recover'", 1000, opts) ~= nil test_run:cmd('delete server err_recovery') diff --git a/test/vinyl/gh-4864-stmt-alloc-fail-compact.result b/test/vinyl/gh-4864-stmt-alloc-fail-compact.result index 6a1f49626b68863cfa17d04d873565e3c0e9ca4d..3b4519b968bc447ea0e9b5aca60e50f7e5baebfa 100644 --- a/test/vinyl/gh-4864-stmt-alloc-fail-compact.result +++ b/test/vinyl/gh-4864-stmt-alloc-fail-compact.result @@ -96,7 +96,7 @@ assert(s.index.pk:stat().run_count == 2) errinj = box.error.injection | --- | ... -errinj.set('ERRINJ_VY_STMT_ALLOC', 0) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', 0) | --- | - ok | ... @@ -115,11 +115,11 @@ assert(s.index.pk:stat().run_count == 1) | --- | - true | ... -assert(errinj.get('ERRINJ_VY_STMT_ALLOC') == -1) +assert(errinj.get('ERRINJ_VY_STMT_ALLOC_COUNTDOWN') == -1) | --- | - true | ... -errinj.set('ERRINJ_VY_STMT_ALLOC', -1) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', -1) | --- | - ok | ... @@ -156,7 +156,7 @@ dump() errinj = box.error.injection | --- | ... -errinj.set('ERRINJ_VY_STMT_ALLOC', 5) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', 5) | --- | - ok | ... @@ -174,11 +174,11 @@ assert(s.index.pk:stat().run_count == 2) | --- | - true | ... -assert(errinj.get('ERRINJ_VY_STMT_ALLOC') == -1) +assert(errinj.get('ERRINJ_VY_STMT_ALLOC_COUNTDOWN') == -1) | --- | - true | ... -errinj.set('ERRINJ_VY_STMT_ALLOC', -1) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', -1) | --- | - ok | ... diff --git a/test/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua b/test/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua index 4b3c55505dd4b47c3574fab94659afc9af5d4b4c..d219a34082d780bc0991fdb9519bf67370b01750 100644 --- a/test/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua +++ b/test/vinyl/gh-4864-stmt-alloc-fail-compact.test.lua @@ -47,7 +47,7 @@ assert(s.index.pk:stat().range_count == 1) assert(s.index.pk:stat().run_count == 2) errinj = box.error.injection -errinj.set('ERRINJ_VY_STMT_ALLOC', 0) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', 0) -- Should finish successfully despite vy_stmt_alloc() failure. -- Still split_range() fails, as a result we get one range -- instead two. @@ -55,8 +55,8 @@ errinj.set('ERRINJ_VY_STMT_ALLOC', 0) compact(1) assert(s.index.pk:stat().range_count == 1) assert(s.index.pk:stat().run_count == 1) -assert(errinj.get('ERRINJ_VY_STMT_ALLOC') == -1) -errinj.set('ERRINJ_VY_STMT_ALLOC', -1) +assert(errinj.get('ERRINJ_VY_STMT_ALLOC_COUNTDOWN') == -1) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', -1) s:drop() @@ -74,15 +74,15 @@ compact(1) dump() errinj = box.error.injection -errinj.set('ERRINJ_VY_STMT_ALLOC', 5) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', 5) -- Compaction of first range fails, so it is re-scheduled and -- then successfully finishes at the second attempt. -- compact(2) assert(s.index.pk:stat().range_count == 2) assert(s.index.pk:stat().run_count == 2) -assert(errinj.get('ERRINJ_VY_STMT_ALLOC') == -1) -errinj.set('ERRINJ_VY_STMT_ALLOC', -1) +assert(errinj.get('ERRINJ_VY_STMT_ALLOC_COUNTDOWN') == -1) +errinj.set('ERRINJ_VY_STMT_ALLOC_COUNTDOWN', -1) -- Unthrottle scheduler to allow next dump. -- errinj.set("ERRINJ_VY_SCHED_TIMEOUT", 0.0001)