{\rtf1\ansi\ansicpg1252\cocoartf2638
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0

\f0\fs24 \cf0 diff --git a/test/cppsuite/src/main/database_operation.cpp b/test/cppsuite/src/main/database_operation.cpp\
index eae21b787..089eeb0ae 100644\
--- a/test/cppsuite/src/main/database_operation.cpp\
+++ b/test/cppsuite/src/main/database_operation.cpp\
@@ -306,25 +306,34 @@ database_operation::remove_operation(thread_worker *tc)\
         scoped_cursor &cursor = cursors[coll.id];\
 \
         /* Choose a random key to delete. */\
-        const char *key_str;\
         int ret = rnd_cursor->next(rnd_cursor.get());\
-        /* It is possible not to find anything if the collection is empty. */\
-        testutil_assert(ret == 0 || ret == WT_NOTFOUND);\
-        if (ret == WT_NOTFOUND) \{\
+\
+        if (ret != 0) \{\
             /*\
-             * If we cannot find any record, finish the current transaction as we might be able to\
-             * see new records after starting a new one.\
+             * It is possible not to find anything if the collection is empty. In that case, finish\
+             * the current transaction as we might be able to see new records after starting a new\
+             * one.\
              */\
-            WT_IGNORE_RET_BOOL(tc->txn.commit());\
+            if (ret == WT_NOTFOUND) \{\
+                WT_IGNORE_RET_BOOL(tc->txn.commit());\
+            \} else if (ret == WT_ROLLBACK) \{\
+                tc->txn.rollback();\
+            \} else \{\
+                testutil_die(ret, "Unexpected error returned from cursor->next()");\
+            \}\
+            testutil_check(rnd_cursor->reset(rnd_cursor.get()));\
             continue;\
         \}\
+\
+        const char *key_str;\
         testutil_check(rnd_cursor->get_key(rnd_cursor.get(), &key_str));\
         if (!tc->remove(cursor, coll.id, key_str)) \{\
             tc->txn.rollback();\
         \}\
 \
-        /* Reset our cursor to avoid pinning content. */\
+        /* Reset our cursors to avoid pinning content. */\
         testutil_check(cursor->reset(cursor.get()));\
+        testutil_check(rnd_cursor->reset(rnd_cursor.get()));\
 \
         /* Commit the current transaction if we're able to. */\
         if (tc->txn.can_commit())}