Fix unsigned underflow in txn_pinned_timestamp_oldest statistic

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: Statistics, Timestamps
    • None
    • Environment:
      GCC 13, Ubuntu 24.04
    • Storage Engines - Transactions
    • 453.914
    • None
    • 1

      The txn_pinned_timestamp_oldest statistic in src/txn/txn.c is calculated as durable_timestamp - oldest_timestamp (line 2408). Since both timestamps are unsigned uint64_t, when durable_timestamp is less than oldest_timestamp, the subtraction underflows and wraps to a very large positive number. Although this value is subsequently cast to int64_t and clamped to 0 in the statistics aggregation phase, the unsigned underflow is still buggy and should be prevented.

      For ReProduce:
      A csuite test (wt<this wt number(I added the WT number later, after this issue was opened>_txn_pinned_timestamp_stat) reproduces the bug and verifies the fix (I attached the before/after outputs on JIRA).

      Purposed Fix:
      Adding a check matching the adjacent lag statistics to ensure the statistic is explicitly set to 0 when durable_timestamp <= oldest_timestamp.

        1. debugprint-after-fix-output.txt
          2 kB
        2. debugprint-before-fix-output.txt
          2 kB
        3. main.c
          6 kB

            Assignee:
            Unassigned
            Reporter:
            Tuna KARABACAK (EXT)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: