Make the monitor the only process that writes the database - #680
Open
rhaegar325 wants to merge 3 commits into
Open
Make the monitor the only process that writes the database#680rhaegar325 wants to merge 3 commits into
rhaegar325 wants to merge 3 commits into
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #680 +/- ##
=======================================
+ Coverage 78.2% 78.5% +0.3%
=======================================
Files 40 41 +1
Lines 8827 8948 +121
Branches 1665 1671 +6
=======================================
+ Hits 6901 7023 +122
Misses 1591 1591
+ Partials 335 334 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Fix #627
Base this PR on
update_monitor, notmain. It sits on top of that branch.The problem
Gadi mounts every Lustre filesystem with
localflock:localflockmakes file locks node-local. SQLite's whole concurrency modelrests on those locks, so the ~100 worker jobs of a batch — one per compute
node — can each believe they hold an exclusive lock on
cmor_tasks.dbandwrite at the same time.
Two runs show the two ways this ends:
The second is the nastier one. SQLite writes whole pages, not rows, and 99
rows share one 4096-byte page. Two nodes read that page, each edit their own
row, and the later write-back discards the earlier one. Nobody gets an error.
Retrying cannot help.
synchronous=FULLcannot help. The fault is locking, notdurability.
The fix
Stop writing the database from more than one node.
Each worker writes only its own file, so there is nothing to contend over.
Writes go through a temp file plus
os.replace, which is atomic on Lustre, sothe monitor never reads a half-written document.
The database keeps exactly the same schema and contents, so the dashboard,
moppy-tuiandmoppy-batch-reportneed no changes.What changed
task_status.py(new)TaskStatusFileplus the readers the monitor uses. Method names mirrorTaskTracker, so the worker diff stays one-for-one.cmor_python_script.j2TaskTrackerat all.tracking.pyapply_worker_status()writes a whole row in one statement, keeping the worker's own timestamps.synchronous=OFF→NORMAL, affordable again now there is one writer.batch_cmoriser.py--append-variablebecomes a request file instead of a database row.qstatstays. Across all past batches, 80 of 455 failures were only everknowable from PBS: the worker was SIGKILLed and never wrote anything. Its
status file is stuck at
runningand only the exit status can settle it.One compatibility note
A
moppy-cmoriseolder than this monitor writes its append request to the oldmonitor_requeststable. That happened during testing and the request wassilently dropped. The monitor now drains that table as well as the file queue,
so a mismatched CLI still works. The shim is commented and can go once no old
CLI is in use.