Kuang-xianxin opened a new pull request, #920: URL: https://github.com/apache/burr/pull/920
`SQLitePersister.load(partition_key, None)` and its async counterpart can return an older checkpoint when several saves share a timestamp. SQLite's default `CURRENT_TIMESTAMP` has second precision, and the current query orders only by that timestamp. In a deterministic reproduction, saving sequence 11 followed by sequence 12 and loading after reopening the database returns sequence 11. Across applications it can also return the wrong app. ## Changes - Use descending `rowid` as the secondary ordering key in the latest-across-apps query, after `created_at`. - Apply the same fix to synchronous SQLite and aiosqlite persistence. - Add deterministic regressions for same-app and cross-app saves, default and explicit partitions, partition isolation, database reopening, and explicit historical lookup. A separate control verifies that timestamps remain the primary ordering key. This uses the rowid already present in tables created by these persisters; no schema migration or change to app-specific sequence selection is needed. The tie-breaker follows insertion order in the persister-managed table, not a portable identifier for externally rewritten database rows. Related: #807 explicitly notes the timestamp-tie limitation in its test-only PR. This PR fixes the behavior in both implementations; it does not duplicate those construction/lifecycle tests or depend on that PR. ## How I tested this Python 3.13.14 on Windows, using actual SQLite/aiosqlite databases: ```text python -m pytest tests/core/test_persistence.py tests/integrations/persisters/test_b_aiosqlite.py -q -k load_latest Before the fix: 8 failed, 2 passed python -m pytest tests/core/test_persistence.py tests/integrations/persisters/test_b_aiosqlite.py tests/core/test_application.py -q --timeout=20 After the fix: 199 passed ``` Pre-commit passes on all four changed files: Black 23.11.0, isort 5.12.0, flake8 6.1.0, whitespace/EOF, AST, and ASF headers. The frontend hook was explicitly skipped because this changes only Python persistence; the full external-database test matrix was not run. ## Notes AI assistance: Codex investigated the behavior, implemented the fix and tests, ran the reported checks, and prepared this PR on behalf of the submitting account. These results describe executed checks and do not claim independent human review. ## Checklist - [x] PR has an informative and human-readable title - [x] Changes are limited to a single goal - [x] Applicable pre-commit checks pass (frontend hook excluded as described above) - [x] Any change in functionality is tested - [x] Existing database format and explicit historical lookup are preserved -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
