Repository navigation
s3queue: fix stale processing state in in-memory metadata - #118111
Conversation
`trySetProcessing` treats a cached `Processing` file status as terminal, so once this table lost the race for the `processing` node in keeper and cached that observation, it never rechecked keeper for that file. Unlike `Processed` and `Failed`, `Processing` is not backed by a persistent node: the processor holding the file can release it without committing it - it can die, or fail the file and reset the node - and nothing resets the cached status. The file stayed skipped by this table until its file status was evicted from the metadata cache or the server restarted. A cached `Processing` state which was observed in keeper rather than set by a processor of this table is now trusted only while it is fresh, bounded by the new table setting `processing_state_cache_ttl_seconds` (300 by default, zero to always recheck keeper). A file released without a commit is therefore retried within the timeout, while a file which really is being processed elsewhere costs one keeper probe per timeout instead of one per listing pass. A `Processing` state owned by a processor of this table stays terminal as before: its owner updates it on commit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Workflow [PR], commit [6be47fa] Summary: ✅
AI ReviewSummaryThis PR fixes the functional stale- Findings💡 Nits
Final VerdictStatus: ✅ Approve LLVM Coverage ReportMeasured on commit 6be47fa.
Changed lines: Changed C/C++ lines covered: 223/225 (99.11%) · Uncovered code |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units21 translation units recompiled, 146 s compile time in total, 21 of them have a recent master baseline. |
`onProcessingByAnotherProcessor` keeps `rows_processed`, `processing_start_time`, `processing_end_time` and `exception` of the last local attempt, while setting the state to `Processing` observed in keeper. `system.s3queue_metadata_cache` documents those columns as the current state of the file, so a local failure followed by a foreign retry showed a `Processing` row carrying an end time and an exception of the previous attempt, with nothing telling the two apart. Expose `foreign_processing_time` as `processing_by_another_server_time`: it is set exactly when the `Processing` status was observed in keeper rather than set by a processor of this server, and in that case the per-attempt columns describe the last local attempt, not the ongoing processing. Co-Authored-By: Claude Opus 5 <[email protected]>
335ec5f to
8b9c315
Compare
| if (file_state.value() == FileStatus::State::Processing) | ||
| file_status->onProcessingByAnotherProcessor(); | ||
| else | ||
| file_status->updateState(file_state.value()); |
There was a problem hiding this comment.
do not see why we do not we handle it inside updateState call
There was a problem hiding this comment.
updateState only knew the target enum, but the policy here depends on provenance, not just the final state. When keeper reports Failed again for a state we already had, we want to keep the local attempt data; when keeper reports a different terminal state, we want to drop it; and only the keeper-observed Processing case should set the observation marker.
That is why the current code replaced the blind setter with onStateObservedInKeeper: it carries the “this came from keeper after a failed claim” context that a generic state setter cannot infer.
…oduce `afterSetProcessing` updated the file status from what keeper has for the file through two different calls, and the one for a committed (`Processed`/`Failed`) state only overwrote the state. It left `foreign_processing_time` set and the data of the last attempt of this server (processed rows, timings, exception) in place, so `system.s3queue_metadata_cache` could show a `Processed` row carrying the marker of the `Processing` state it replaced and the exception of an earlier local failure. Both calls are replaced by `onStateObservedInKeeper`, which keeps the data of the local attempt only while it can still describe the observed state: for a state we did not have before, `resetAttempt` drops that data together with the marker. An own `Failed` node observed again keeps its exception, which is what that state is about. `trySetProcessing` also consulted the file status before taking the processing lock, so it could miss a `Processing` state which a processor of this server was setting under that lock and mark it as foreign. The check is moved under the lock, as `prepareSetProcessingRequests` already did it, and committing a file now clears the marker, which also covers the batched claim path, where the state is set after the lock is released. The transitions are covered by a new unit test: they are reachable in production only through a race between listing a file and claiming it, because a file which keeper already has a `processed`/`failed` node for is filtered out of the listing. `test_retry_file_released_by_another_processor` is also parametrized over `enable_hash_ring_filtering` now, so that the batched claim path, which shares the `Processing` state cache check, is covered as well. Co-Authored-By: Claude Opus 5 <[email protected]>
…gn-processing-state
`ObjectStorageQueueExclusiveFileMetadata`, added on master in the meantime, does not compile against the constructor of `ObjectStorageQueueIFileMetadata` of this branch, which takes the new `processing_state_cache_ttl_seconds` setting. Co-Authored-By: Claude Opus 5 <[email protected]>
…ther server `processing_by_another_server_time` promised more than the marker knows. It is set whenever a processor failed to take the file and read the `Processing` state from keeper, and the processor which holds the file is usually on another server, but it can also be one of this server which had just taken it - the case the unit test of the previous commit pins down. As the column is new in this pull request, name it after what it records: `processing_observed_in_keeper_time`. Co-Authored-By: Claude Opus 5 <[email protected]>
`system.s3queue_metadata_cache.status` listed three states, but the cache also dumps `None`, which a file gets when its processing is reset. And the description of `processing_state_cache_ttl_seconds` claimed the timeout applies to the in-memory `Processing` state in general, while `hasNonProcessableState` applies it only to a state read from keeper: a `Processing` state owned by a processor of this server stays terminal, because its owner updates it itself. Both strings are autogenerated into the documentation, so they are what an operator reads. Co-Authored-By: Claude Opus 5 <[email protected]>
…-processing-node-cache Master merged #118111, which fixes the core bug of this pull request with its own design: `processing_state_cache_ttl_seconds` (kept in the shared `ObjectStorageQueueMetadata`) and `FileStatus::processing_observed_in_keeper_time` / `onStateObservedInKeeper`. The merge adopts that design and drops the duplicate one of this branch: `foreign_processing_node_cache_ttl_seconds`, the per-table `ForeignProcessingObservers` registry and its generation scoping. What this branch adds on top is kept on the new primitives: the terminal-state write-back of the listing pre-filter and of the set-processing probe (`FileTerminalState`), the terminal-state generation guard against a loser of the `processing` race, the foreign-processing recheck lists and the wake-up cap of the streaming task, and the ordered-mode blocking of an ordering domain behind a foreign-held file (with the replay cap). The gtests of the removed registry and the two integration tests pinning per-table observation deadlines are dropped, the rest is renamed to the setting of master. Co-Authored-By: Claude Fable 5.1 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
In S3(Azure)Queue table engine fix stale processing state in in-memory metadata
Workflow [PR]
Sync PR [sync-upstream/pr/118111]
Version info
26.9.1.1577(included in26.9and later)