Conversation
Closes Tx-wats#5. `AppConfig::cursor_file` is documented as "write the updated cursor map after each poll cycle", and the poller reads it on startup — but nothing ever wrote it. `save_cursors` was only called from `run_once`, so the continuous engine never persisted anything. After a restart the poller reloaded whatever cursor was in the file originally (or `now`), so transactions were either replayed from a stale cursor, producing duplicate alerts, or skipped entirely. - `write_cursor_file` writes a temp file in the same directory, fsyncs it, renames it over the target and fsyncs the directory, so neither a half-written file nor a lost rename can survive a crash. Previously `fs::write` + `rename` with no fsync at all. - Each contract's task shares the cursor map and, after a cycle that advanced its own cursor, updates the shared map and writes the file under the lock, so concurrent tasks cannot clobber each other's entry. - The cursor is flushed again when the tasks are drained, so a graceful shutdown persists anything advanced since the last per-cycle write. - A poisoned lock recovers its contents rather than taking the poller down. `poll_contract_forever` picks its starting cursor from the shared map, so it no longer needs the cursor passed in. The new integration test drives the real polling loop and fails on the parent commit with "cursor file never contained the served paging token" after its 15s deadline; it also asserts the temp file is not left behind.
|
@ayomidearegbeshola29-dev Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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 #5.
Problem
AppConfig::cursor_fileis documented as "write the updated cursor map after each poll cycle", and the poller reads it on startup — but nothing ever wrote it.save_cursorswas called only fromrun_once, so the continuous engine never persisted anything.After a restart the poller reloaded whatever cursor was in the file originally (or
now), so transactions were either replayed from a stale cursor, producing duplicate alerts, or skipped entirely.Change
write_cursor_filewrites a temp file in the same directory, fsyncs it, renames it over the target, and fsyncs the directory. Neither a half-written file nor a lost rename can survive a crash. Previously this wasfs::write+renamewith no fsync at all.poll_contract_forevernow reads its starting cursor from the shared map, so it no longer needs it passed in.Testing
The new integration test drives the real polling loop, waits for the cursor file to contain the paging token the mock actually served, and asserts the temp file is not left behind.
It fails on the parent commit with
cursor file never contained the served paging tokenafter its 15s deadline, so it is testing the fix rather than the pre-existing behaviour.cargo fmt --all -- --checkcargo clippy -p txwatch-poller --all-targets --all-featurescargo test -p txwatch-poller— 33 lib + 16 integration + attack tests, all passingNote on the diff
This branch stacks on the build repair in #169, which is not merged yet, so the repair commits are included. They are unrelated to this fix and can be dropped once #169 lands.