Reset MARC files on settings update (PP-4637)#3554
Conversation
|
Claude finished @tdilauro's task in 9m 55s —— View job Code ReviewI reviewed the reset task, the in-flight drift detection ( SummaryThis is a carefully-constructed change and it holds up under scrutiny. I verified the parts most likely to hide a defect and they're correct: S3 keys embed a |
Greptile SummaryThis PR resets MARC export state when export-affecting settings change. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (8): Last reviewed commit: "Code review feedback" | Re-trigger Greptile |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #3554 +/- ##
==========================================
+ Coverage 93.50% 93.51% +0.01%
==========================================
Files 512 512
Lines 46640 46754 +114
Branches 6358 6378 +20
==========================================
+ Hits 43612 43724 +112
Misses 1959 1959
- Partials 1069 1071 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
29c50fe to
cfe7cfb
Compare
jonathangreen
left a comment
There was a problem hiding this comment.
Looks good! A couple comments to think about, but this could be merged as is.
| # regenerated from unchanged settings by the next scheduled export run. | ||
| if reset_library_ids: | ||
| for library_id in reset_library_ids: | ||
| marc_export_reset.delay(library_id) |
There was a problem hiding this comment.
You might want to add a cooldown here. I've been bitten before where, surprisingly (to me at least), the background task starts before the transaction commits, so it gets old settings.
There was a problem hiding this comment.
I wasn't too worried about the settings here, since this reset is just deleting the records. The reset task itself doesn't read settings, so running early wouldn't feed it stale data. But the cooldown does fix another problem. We queue the reset just before saving the settings change, so it was possible for the reset to run before the save landed. We could (if we were really unlucky) have an export that was finishing at that exact moment that could have its files survive our checks and keep content generated with the old settings available (I went back and forth with the AI reviewers about this). So, the cooldown will help ensure that the reset always runs after the settings are saved, which is what our checks assume.
| if reset_library_ids: | ||
| for library_id in reset_library_ids: | ||
| marc_export_reset.delay(library_id) | ||
| self._db.commit() |
There was a problem hiding this comment.
Do we want to add an explicit commit here? I think you can rely on the commit done by the controller instead of adding another here.
There was a problem hiding this comment.
I'm adopting the cooldown from your previous comment, so it should be safe to remove this commit.
| dumped[field] = sorted(dumped[field]) | ||
| return dumped | ||
|
|
||
| return comparable(snapshot) != comparable(current) |
There was a problem hiding this comment.
Minor: Might want to consider using json_canonical util (or maybe some generalized version) for this.
There was a problem hiding this comment.
Thanks for the tip! 🎉
b48752e to
6b28aee
Compare
Description
marc_export_resetCelery task that sets up the next MARC export as a first run by removing existing files (database records and S3 objects). The records are deleted in one transaction, and S3 deletion is best-effort, so a failure won't leave the reset half-applied.Motivation and Context
MARC record exports run periodically, but a configuration change would not trigger an update. Record updates based on those changes might not become available until long after the change was made. Further, some MARC consumers apply only delta files rather than reprocessing full exports. When a library's MARC export configuration changed (organization code, summary/genre inclusion, web client URLs), records exported before the change were never corrected for those consumers, leaving stale data in their catalogs indefinitely. Resetting the library's export state on configuration changes forces a full refresh that reaches both full-file and delta-only consumers.
[Jira PP-4637]
How Has This Been Tested?
Checklist