Unit test aborted when trying to delete HS record

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Storage Engines
    • SE Transactions - 2025-09-26
    • 5

      Found a bug when trying to delete a HS record, can be reproduced with this unit test:

       

      #!/usr/bin/env python
      #
      # Public Domain 2014-present MongoDB, Inc.
      # Public Domain 2008-2014 WiredTiger, Inc.
      #
      # This is free and unencumbered software released into the public domain.
      #
      # Anyone is free to copy, modify, publish, use, compile, sell, or
      # distribute this software, either in source code form or as a compiled
      # binary, for any purpose, commercial or non-commercial, and by any
      # means.
      #
      # In jurisdictions that recognize copyright laws, the author or authors
      # of this software dedicate any and all copyright interest in the
      # software to the public domain. We make this dedication for the benefit
      # of the public at large and to the detriment of our heirs and
      # successors. We intend this dedication to be an overt act of
      # relinquishment in perpetuity of all present and future rights to this
      # software under copyright law.
      #
      # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
      # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
      # OTHER DEALINGS IN THE SOFTWARE.
      #
      # test_prepare_discover03.py
      #   Test that prepare discover cursor should return an error when closed with unclaimed prepared transactionsimport wiredtiger
      from suite_subprocess import suite_subprocess
      import wttest
      from wtscenario import make_scenariosclass test_prepare_discover03(wttest.WiredTigerTestCase, suite_subprocess):
          tablename = 'test_prepare_discover03'
          uri = 'table:' + tablename
          conn_config = 'precise_checkpoint=true,preserve_prepared=true'
          s_config = 'key_format=i,value_format=S'    def test_prepare_discover03(self):
              self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(50))
              self.conn.set_timestamp('oldest_timestamp=' + self.timestamp_str(50))
              self.session.create(self.uri, self.s_config)
              c = self.session.open_cursor(self.uri)        self.session.begin_transaction()
              c[1] = "commit ts=60"
              c[2] = "commit ts=60"
              self.session.commit_transaction("commit_timestamp=" + self.timestamp_str(60))        # Insert a few keys then prepare the transaction
              self.session.begin_transaction()
              c[3] = "prepare ts=100"
              c[4] = "prepare ts=100"
              c[5] = "prepare ts=100"
              # Prepare with a timestamp greater than current stable
              self.session.prepare_transaction('prepare_timestamp=' + self.timestamp_str(100) +',prepared_id=' + self.prepared_id_str(123))        session2 = self.conn.open_session()
              c2 = session2.open_cursor(self.uri)
              session2.begin_transaction()
              c2[1] = "prepare ts=100"
              c2[2] = "prepare ts=100"
              session2.prepare_transaction('prepare_timestamp=' + self.timestamp_str(100) +',prepared_id=' + self.prepared_id_str(150))
              # Move the stable timestamp to include the prepared transaction
              self.conn.set_timestamp('stable_timestamp=' + self.timestamp_str(150))
              # Create a checkpoint
              session3 = self.conn.open_session()
              session3.checkpoint()        # Creating backup that will preserve artifacts
              backup_dir = 'bkp'
              self.backup(backup_dir, session3)        # Opening backup database
              conn2 = self.wiredtiger_open(backup_dir, self.conn_config)
              c2s1 = conn2.open_session()        # Opening prepared discover cursor
              prepared_discover_cursor = c2s1.open_cursor("prepared_discover:")        # Walking through prepared discover cursor
              c2s2 = conn2.open_session()
              count = 0
              while prepared_discover_cursor.next() == 0:
                  count += 1
                  prepared_id = prepared_discover_cursor.get_key()
                  # self.assertEqual(prepared_id, 123)
                  c2s2.begin_transaction("claim_prepared_id=" + self.timestamp_str(prepared_id))
                  c2s2.commit_transaction("commit_timestamp=" + self.timestamp_str(200)+",durable_timestamp=" + self.timestamp_str(210))
                  # if count == 1:
                  #     break
              # Try to claim an already claimed prepared transaction, should return an error
              prepared_discover_cursor.close()
              c2s2.close()
              conn2.set_timestamp('stable_timestamp=' + self.timestamp_str(220))
              c2s3 = conn2.open_session()
              c2s3.checkpoint()

      when running this test, the code abort with this issue:

      libc.so.6!__pthread_kill_implementation(pthread_t threadid, int signo, int no_tid) (pthread_kill.c:44)
      libc.so.6!__pthread_kill_internal(int signo, pthread_t threadid) (pthread_kill.c:78)
      libc.so.6!__GI_raise(int sig) (raise.c:26)
      libc.so.6!__GI_abort() (abort.c:79)
      _wiredtiger.so!__wt_abort(WT_SESSION_IMPL * session) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/os_common/os_abort.c:31)
      _wiredtiger.so!__rec_hs_delete_record(WT_SESSION_IMPL * session, WTI_RECONCILE * r, WT_ITEM * key, WT_UPDATE * upd, WT_UPDATE * tombstone) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_hs.c:1306)
      _wiredtiger.so!__wti_rec_hs_delete_updates(WT_SESSION_IMPL * session, WTI_RECONCILE * r) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_hs.c:1360)
      _wiredtiger.so!__rec_hs_wrapup(WT_SESSION_IMPL * session, WTI_RECONCILE * r) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_write.c:3498)
      _wiredtiger.so!__rec_write_wrapup(WT_SESSION_IMPL * session, WTI_RECONCILE * r) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_write.c:3175)
      _wiredtiger.so!__reconcile(WT_SESSION_IMPL * session, WT_REF * ref, WT_SALVAGE_COOKIE * salvage, uint32_t flags, _Bool * page_lockedp) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_write.c:363)
      _wiredtiger.so!__wt_reconcile(WT_SESSION_IMPL * session, WT_REF * ref, WT_SALVAGE_COOKIE * salvage, uint32_t flags) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/reconcile/rec_write.c:124)
      _wiredtiger.so!__wt_sync_file(WT_SESSION_IMPL * session, WT_CACHE_OP syncop) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/btree/bt_sync.c:364)
      _wiredtiger.so!__checkpoint_tree(WT_SESSION_IMPL * session, _Bool is_checkpoint, const char ** cfg) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:2560)
      _wiredtiger.so!__checkpoint_tree_helper(WT_SESSION_IMPL * session, const char ** cfg) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:2698)
      _wiredtiger.so!__checkpoint_apply_to_dhandles(WT_SESSION_IMPL * session, const char ** cfg, int (*)(WT_SESSION_IMPL *, const char **) op) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:340)
      _wiredtiger.so!__checkpoint_db_internal(WT_SESSION_IMPL * session, const char ** cfg) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:1343)
      _wiredtiger.so!__checkpoint_db_wrapper(WT_SESSION_IMPL * session, const char ** cfg) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:1734)
      _wiredtiger.so!__wt_checkpoint_db(WT_SESSION_IMPL * session, const char ** cfg, _Bool waiting) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/checkpoint/checkpoint_txn.c:1813)
      _wiredtiger.so!__session_checkpoint(WT_SESSION * wt_session, const char * config) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/src/session/session_api.c:2363)
      _wiredtiger.so!_wrap_Session_checkpoint(PyObject * self, PyObject * args) (/home/ubuntu/dev/wiredtiger.worktrees/wt-15343/cmake-build-debug/lang/python/CMakeFiles/wiredtiger_python.dir/wiredtigerPYTHON_wrap.c:7623) 

            Assignee:
            [DO NOT USE] Backlog - Storage Engines Team
            Reporter:
            Linh Tran
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: