Skip to content

Conversation

@corylanou
Copy link
Collaborator

Summary

  • Adds validation to ensure snapshot LTX files contain all expected pages
  • Implements the TODO comment in decoder.go about verifying last read page equals commit for snapshots
  • Adds comprehensive tests for snapshot completeness validation

Changes

  • Modified decoder.go to track the last page number read and validate it matches the expected value for snapshots
  • Added TestDecoder_SnapshotCompleteness with four test cases:
    • Complete snapshot validation
    • Incomplete snapshot detection
    • Special handling for lock page boundary
    • Non-snapshot files are not validated

Implementation Details

The decoder now tracks lastPgno during page reads and validates during Close() that:

  • For snapshots (MinTXID=1), all pages from 1 to Commit have been read
  • Special case: when Commit equals the lock page number, we expect the last page to be Commit-1 (since the lock page is never written)
  • Non-snapshot files are not subject to this validation

This ensures snapshot files are complete and haven't been truncated or corrupted.

🤖 Generated with Claude Code

- Implement validation to ensure snapshots contain all expected pages
- Track lastPgno during page decoding
- Add comprehensive tests for snapshot completeness validation
- Handle special case where commit equals lock page number
- Resolves TODO: Ensure last read page is equal to the commit for snapshot LTX files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants