From 3b59f4eb243ccf479f548de61efa4886cd677c8a Mon Sep 17 00:00:00 2001
From: Aleksandr Lyapunov <alyapunov@tarantool.org>
Date: Fri, 13 Aug 2021 10:01:49 +0300
Subject: [PATCH] txm: check memtx_tx_handle_gap_write return code

The return code was not checked and thus in case of memory error
we could loose conflicts. Fix it.

Follow up #6040
---
 src/box/memtx_tx.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/src/box/memtx_tx.c b/src/box/memtx_tx.c
index 92aab79347..df60b9e710 100644
--- a/src/box/memtx_tx.c
+++ b/src/box/memtx_tx.c
@@ -1431,9 +1431,11 @@ memtx_tx_history_add_insert_stmt(struct txn_stmt *stmt,
 		replaced_story = memtx_tx_story_get(replaced);
 		memtx_tx_story_link_top_light(add_story, replaced_story, 0);
 	} else {
-		memtx_tx_handle_gap_write(stmt->txn, space,
-					  add_story, new_tuple,
-					  direct_successor[0], 0);
+		rc = memtx_tx_handle_gap_write(stmt->txn, space,
+					       add_story, new_tuple,
+					       direct_successor[0], 0);
+		if (rc != 0)
+			goto fail;
 	}
 
 	/* Purge found conflicts. */
@@ -1448,9 +1450,11 @@ memtx_tx_history_add_insert_stmt(struct txn_stmt *stmt,
 		replaced_story->link[0].in_index = NULL;
 	for (uint32_t i = 1; i < space->index_count; i++) {
 		if (directly_replaced[i] == NULL) {
-			memtx_tx_handle_gap_write(stmt->txn, space,
-						  add_story, new_tuple,
-						  direct_successor[i], i);
+			rc = memtx_tx_handle_gap_write(stmt->txn, space,
+						       add_story, new_tuple,
+						       direct_successor[i], i);
+			if (rc != 0)
+				goto fail;
 			continue;
 		}
 		assert(directly_replaced[i]->is_dirty);
-- 
GitLab