diff --git a/src/box/memtx_hash.cc b/src/box/memtx_hash.cc index bc02721a8bab15dfbf7cc9fe7ab6644cb23aa268..b80c05c2127c3503daffef992def17f00080eb56 100644 --- a/src/box/memtx_hash.cc +++ b/src/box/memtx_hash.cc @@ -371,15 +371,13 @@ memtx_hash_index_replace(struct index *base, struct tuple *old_tuple, if (pos == light_index_end) pos = light_index_insert(hash_table, h, new_tuple); - ERROR_INJECT(ERRINJ_INDEX_ALLOC, - { + ERROR_INJECT(ERRINJ_HASH_INDEX_REPLACE, { light_index_delete(hash_table, pos); pos = light_index_end; }); if (pos == light_index_end) { - diag_set(OutOfMemory, - (ssize_t)light_index_count(hash_table), + diag_set(OutOfMemory, MEMTX_EXTENT_SIZE, "hash_table", "key"); return -1; } diff --git a/src/lib/core/errinj.h b/src/lib/core/errinj.h index 085a74479c9bfd2202ce16a59c40a9ad76c9550f..7d878efe45a283d8626e06516e5a660b654b6347 100644 --- a/src/lib/core/errinj.h +++ b/src/lib/core/errinj.h @@ -94,6 +94,7 @@ struct errinj { _(ERRINJ_INDEX_ALLOC, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_INDEX_RESERVE, ERRINJ_BOOL, {.bparam = false})\ _(ERRINJ_INDEX_ITERATOR_NEW, ERRINJ_BOOL, {.bparam = false}) \ + _(ERRINJ_HASH_INDEX_REPLACE, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_IPROTO_CFG_LISTEN, ERRINJ_INT, {.iparam = 0}) \ _(ERRINJ_IPROTO_DISABLE_ID, ERRINJ_BOOL, {.bparam = false}) \ _(ERRINJ_IPROTO_DISABLE_WATCH, ERRINJ_BOOL, {.bparam = false}) \ diff --git a/test/box/errinj.result b/test/box/errinj.result index 53ea6b353c1fc051aadd22964653f8be05e62f05..0f47135996f71d4fc0a9d3fd41d280dfae0156a7 100644 --- a/test/box/errinj.result +++ b/test/box/errinj.result @@ -63,6 +63,7 @@ evals - ERRINJ_FIBER_MPROTECT: -1 - ERRINJ_FLIGHTREC_LOG_DELAY: 0 - ERRINJ_FLIGHTREC_RECREATE_RENAME: false + - ERRINJ_HASH_INDEX_REPLACE: false - ERRINJ_HTTPC_EXECUTE: false - ERRINJ_HTTP_RESPONSE_ADD_WAIT: false - ERRINJ_INDEX_ALLOC: false diff --git a/test/box/errinj_index.result b/test/box/errinj_index.result index f3943dccac9fafc18e97b34e11a62221ef17ce3b..ec1f7209ade1bbca5338b698a7b3efabe20dd988 100644 --- a/test/box/errinj_index.result +++ b/test/box/errinj_index.result @@ -489,6 +489,18 @@ res - [5009, 5009] - [5010, 5010] ... +errinj.set("ERRINJ_HASH_INDEX_REPLACE", true) +--- +- ok +... +s:replace{3594, 3594} +--- +- error: Failed to allocate 16384 bytes in hash_table for key +... +errinj.set("ERRINJ_HASH_INDEX_REPLACE", false) +--- +- ok +... s:drop() --- ... diff --git a/test/box/errinj_index.test.lua b/test/box/errinj_index.test.lua index 6068965ee2b81012e967031d2adf5d77e5a00eec..f6ab00757e93f741e2af8cdfa21734b60cdab1ec 100644 --- a/test/box/errinj_index.test.lua +++ b/test/box/errinj_index.test.lua @@ -121,6 +121,11 @@ res res = {} for i = 5001,5010 do table.insert(res, (s:get{i})) end res + +errinj.set("ERRINJ_HASH_INDEX_REPLACE", true) +s:replace{3594, 3594} +errinj.set("ERRINJ_HASH_INDEX_REPLACE", false) + s:drop() errinj = nil