Stage A of review fixes: single read snapshot, redacted /health, batched diff

/addresses reads the cursor and data in one session and one snapshot,
/health exposes only time and backup file name of the last restore,
get_changes checks presence in batches instead of per value (6.8 s -> 88 ms
on a 12k-entry journal). Adds the plan for review fixes 5-10.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5 committed 2026-09-21 10:06:31 +03:00
1 parent 0155fd3f38
commit d6b69d0842
6 files changed
+103 -33

No files matched your search

+11
View File
@@ -83,6 +83,17 @@ def test_change_journal(files):
assert db.get_changes(conn, {"asn"}, cursor=c3 + 1) is None
assert db.get_changes(conn, {"asn"}, cursor=c3) == (set(), set(), c3)
# Пакет больше порции проверки наличия (PRESENCE_BATCH): результат полный и точный
head = db.journal_head(conn)
bulk = {f"10.{i // 250}.{i % 250}.0/24" for i in range(2 * db.PRESENCE_BATCH + 200)}
with db.transaction(conn):
db.merge_source(conn, "asn", "3", bulk, now, 90)
assert db.get_changes(conn, {"asn"}, cursor=head)[:2] == (bulk, set())
head = db.journal_head(conn)
with db.transaction(conn):
db.purge_source(conn, "asn", "3")
assert db.get_changes(conn, {"asn"}, cursor=head)[:2] == (set(), bulk)
def test_backup_rotation_and_integrity(files):
now = datetime.datetime.now()