Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-2574

PurgeTxnLog can inadvertently delete required txn log files

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.4.7, 3.4.8, 3.5.0, 3.5.1, 3.5.2
    • Fix Version/s: 3.4.10, 3.5.3, 3.6.0
    • Component/s: server
    • Labels:
      None
    • Environment:

      Zookeeper 3.4.8, standalone, and 3-server quorum

      Description

      As part of the fix for ZOOKEEPER-1797, the call to FileTxnSnapLog.getSnapshotLogs() was removed from PurgeTxnLog.java. As a result, some old-looking but required txn log files can be deleted, resulting in data corruption or loss.

      For example, consider the following:

      1. Configuration:
      autopurge.snapRetainCount=3

      2. Following files exist:
      log.100 spans transactions from zxid=100 till zxid=140 (inclusive)
      snapshot.110 - snapshot as of zxid=110
      snapshot.120 - snapshot as of zxid=120
      snapshot.130 - snapshot as of zxid=130

      Above scenario is possible when snapshotting has happened multiple times but without accompanying log rollover, which is possible if the server was running as a learner.

      3. PurgeTxnLog retains all snapshots but deletes log.100 because its zxid is older than the zxid of the oldest snapshot (110). This results in loss of transactions in the range 131-140.

      Before the fix for ZOOKEEPER-1797, this was avoided by the call to FileTxnSnapLog.getSnapshotLogs() which finds and retains the newest txn log file with starting zxid < oldest retained snapshot's highest zxid.

        Attachments

        1. ZOOKEEPER-2574.2.patch
          10 kB
          Abhishek Rai
        2. ZOOKEEPER-2574.3.patch
          11 kB
          Abhishek Rai
        3. ZOOKEEPER-2574.4.patch
          13 kB
          Abhishek Rai
        4. ZOOKEEPER-2574.5.patch
          11 kB
          Abhishek Rai
        5. ZOOKEEPER-2574.6.patch
          12 kB
          Abhishek Rai
        6. ZOOKEEPER-2574.patch
          11 kB
          Abhishek Rai

          Issue Links

            Activity

              People

              • Assignee:
                abhishekrai Abhishek Rai
                Reporter:
                abhishekrai Abhishek Rai
              • Votes:
                0 Vote for this issue
                Watchers:
                8 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: