Repository navigation
Backfill the data half of the Modified date from Edit Journals and Bulk Load Events - #2589
Merged
Merged
Conversation
`manage.py backfill_data_modified` fills Table.data_modified from the later of the latest applied Edit Journal change and the latest successful Bulk Load Event. Tables with neither stay NULL. Dry run by default; --apply writes. - Only a NULL is filled, tested in the UPDATE's own WHERE, so a stamp from any write since the release wins, including one landing during the run, and a second run writes nothing. - The OEDB is only read: journals are found in the catalog first, get_sa_table (which creates a missing journal) is never called, and every read runs in a READ ONLY transaction, one per 200 journals. One transaction for all of them runs out of the server's lock table at a few thousand journals. - A journal two Tables' names clip to is skipped and counted. - metadata_modified and date_updated are never touched. benchmarks/tables_tab/backfill_cost.py times it on a throwaway database: 300 Tables, 525 journals of 1,000 rows, 46 ms dry run. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2558
Slice 6 of #2551. #2557 added
Table.data_modifiedandmetadata_modified, stamped from then on. This fills the data half for Tables that changed before, where a date can be recovered.What it does
python manage.py backfill_data_modified [--apply], dry run by default.The date is the later of:
_<schema>._<name>_insert/_edit/_delete). A change still waiting for Apply never reached the Main Table, so it does not count;A Table with neither stays NULL and reads "–".
Only a NULL is filled, and that test is in the UPDATE's own
WHERE. A stamp from any write since the release therefore wins, including one landing during the run, and a second run writes nothing.Never touched:
metadata_modified(no metadata save was ever timestamped) anddate_updated(for older Tables it holds a date copied out of their metadata).Output: the dry run counts the sources (journal only / bulk only / both / neither / already dated) and how many Tables it would date.
--applyreports how many got a date, and how many were stamped meanwhile and left alone.The OEDB is only read
pg_class, with the three columns the read needs), and only those that exist are read.get_sa_tableis never called on a Journal Table, because it creates the journal when it is missing (oedb/utils.py,_OedbMetaTable.get_sa_table→_create_if_missing). A test pins that no journal exists after either run.READ ONLYtransaction, one per 200 journals.out of shared memoryAdd edit-journal / speed up row inserts using current revision system #2363's first version hit, and a read locks the journal and its index until the transaction ends.ORDER BY _id DESC LIMIT 1, because_idcomes from one shared sequence. It is batched in aUNION ALLper chunk, not one query per Table._submitted(atimestamp without time zonefrom the OEDB'snow()) is read backAT TIME ZONE current_setting('TimeZone'), the zone it was written in.Cost
benchmarks/tables_tab/backfill_cost.pyuses a throwaway database, likedelete_cost.py. Measured locally: 300 Tables, 525 journals of 1,000 rows: 46 ms dry run, 74 ms--apply. A 2,000-Table run was spoiled by another session's API tests emptying the shared sandbox schema mid-run, so it is not quoted.Deploy
One command, no migration, no internet. Run it once after
migratehas applieddataedit.0056, on the host, where the OEDB is reachable. The step is in the vault's deploy checklist for the next release.Tests
9 tests in
dataedit/tests/test_backfill_data_modified.py, throughcall_command, against real Journal Tables in the sandbox:date_updateduntouched;🤖 Generated with Claude Code