Skip to content

Keep an S3Queue file retryable after losing the race for its processing node - #112313

Open
alexey-milovidov wants to merge 110 commits into
masterfrom
fix-s3queue-foreign-processing-node-cache
Open

alexey-milovidov wants to merge 110 commits into
masterfrom
fix-s3queue-foreign-processing-node-cache

Conversation

@alexey-milovidov

@alexey-milovidov alexey-milovidov commented Jul 28, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Fix S3Queue/AzureQueue in ordered mode losing a file which is held by the processing node of another processor: committing a later file of the same bucket (or partition) advanced the processed pointer past the held file, and if the other processor then released the file without committing it, the file was never ingested. Also make system.s3queue_metadata_cache follow Keeper when another processor commits or fails a file, retry a file skipped because of a foreign processing node within processing_state_cache_ttl_seconds even on an idle queue, and carry the exception of a failed node committed by another processor into the cache.

Description

Found during the review of #108977 (the regression test there has to accept losing one file for exactly this reason).

The original bug of this pull request - a file whose processing node belongs to another processor was cached as Processing and never retried by this table, even after the other processor released it without a commit - has meanwhile been fixed on master by #118111: the cached Processing state carries FileStatus::processing_observed_in_keeper_time, and it is trusted for the table setting processing_state_cache_ttl_seconds (5 minutes by default, zero means to always check Keeper). This pull request builds on those primitives (its own registry and setting were dropped when master was merged) and keeps what is not covered by that fix:

Ordered mode: a foreign-held file blocks the later files of its ordering domain. An ordering domain is the scope of one processed pointer: a bucket, and a partition within it when partitioning is used. Committing a later file of the domain advances the pointer past the held file, and the next listing pass then drops the held file as already processed - losing it forever if the foreign processor never commits it (it can die; its persistent processing node is only cleaned up after persistent_processing_node_ttl_seconds). The file iterator records foreign-held files per ordering domain and drops the later files of the domain both at the listing pre-filter and before handing a file out; they are re-listed by the next pass. A held file stops blocking its domain as soon as this server wins its processing node or a terminal state for it is discovered in Keeper. The dropped files are retained in memory so that they can be replayed as soon as the blocker resolves, but the retention is only a shortcut and is capped at 1000 files: a blocker near the beginning of a large domain would otherwise buffer the whole rest of the namespace. Beyond the cap the files are not retained and the next pass lists them again. Because the blocker can resolve in the middle of the pass, the smallest path dropped by the cap is remembered per domain and everything from it on stays blocked for the rest of the pass, otherwise the files listed after the dropped range would advance the pointer past it. With several processing threads sharing one ordering domain (buckets = 1) the block alone is not enough: it is recorded only when the set-processing attempt of the held file fails, and a later file handed out to another thread before that could still be committed first. The file iterator therefore registers a file whose set-processing outcome is not yet known at hand-out time, and a later file of the domain waits until the outcomes of the smaller files are known before starting its own attempt.

Rechecks within a listing pass and on an idle queue. A file skipped because of a trusted foreign Processing observation is kept in a recheck list by the file iterator, and every batch boundary of the pass takes the files whose observation has expired and runs them through the regular filtering, so the TTL is honored with batch granularity within a long pass. The streaming task also schedules its next cycle no later than the earliest pending recheck deadline, so that the TTL bounds the retry latency even when the polling backoff after zero-row cycles far exceeds it. That wake-up cap applies only to cycles which actually consume the iterator: a SYSTEM STOP/SYSTEM PAUSEd table never consumes it, so an overdue recheck must not make the background task reschedule in a tight loop.

system.s3queue_metadata_cache follows Keeper. The terminal states which the listing pre-filter discovers in Keeper are written back into the cached FileStatus (unless the state is owned by an active local processor, whose owner updates it on commit), so the cache does not keep a stale Processing after another processor has committed the file. The write-back replaces the whole record: the per-attempt data of an abandoned local attempt is cleared, and a file failed by another processor carries the exception and retries from the failed node. It is skipped when the cached state already equals the discovered terminal state (a finished local attempt whose rows_processed and timings must survive relistings); a cached Failed, however, also describes retriable local attempts, so it is kept only when its retry count matches the failed node payload. The set-processing probe (trySetProcessing/prepareSetProcessingRequests) follows the same contract: when it discovers a processed/failed node, it returns the metadata of that node and afterSetProcessing refreshes the whole cached record with the same guards. A failed node has precedence over the bucket-level processed pointer in the pre-filter, because a later file may advance that pointer while a failed node for an earlier file remains in Keeper.

Two writers of one shared record are ordered. The cached record of a file is shared between the tables of one keeper_path. The pre-filter write-back takes the same processing_lock the set-processing probe holds, and the record keeps a terminal-state generation counter which the probe snapshots before reading Keeper, so a table which lost the race for the processing node cannot downgrade a record which another table has meanwhile refreshed to processed/failed. A same-server contender losing to a concurrent local processor also keeps the locally owned Processing state untouched instead of marking it as observed in Keeper: the owner updates it itself, and a false marker would make the other tables of this server block the ordering domain behind a file this server is processing.

Tests: tests/integration/test_storage_s3_queue/test_foreign_processing_node.py (12 tests) emulates the foreign processor with a real processing node in Keeper. They cover the retry after the node disappears in unordered and ordered mode; the later files of an ordering domain waiting for a held file in the middle of it; two processing threads over one domain with the set-processing attempt of the smallest file parked at a failpoint; the domain kept blocked when the replay cap drops files and the blocker resolves mid-pass (1102 files, a failpoint right after the first drop); the cache reporting Processed/Failed (with the foreign exception) instead of a stale Processing; a failed node appearing between the initial state read and the multi request of the ordered set-processing attempt; a terminal failed node replacing a cached retriable local failure; a failed node taking precedence over the processed pointer; the retry within the TTL on an idle queue with a two-minute polling backoff; a paused table not busy-looping on an overdue recheck; and ALTER TABLE ... MODIFY SETTING processing_state_cache_ttl_seconds shortening the retry window of a running table. src/Storages/ObjectStorageQueue/tests/gtest_file_status_foreign_processing.cpp covers the shared FileStatus state machine: the same-server contention case, the trust window of an observed Processing state, the whole-record refresh on a terminal state discovered by the set-processing probe, the retriable-vs-terminal Failed guard, and the loser of the processing race not clobbering a terminal record refreshed by another table. The members added here are referenced from if constexpr (requires ...) branches, so the gtest also compiles at the merge base (where it fails at runtime), which is what the Bugfix validation (unit tests) job checks.

The remaining ordered-mode gap raised by the AI review - a later file committed by another source of the same table while a smaller file is only locally Processing and is then reset without a failed node - is pre-existing on master and independent of foreign processors; it is tracked separately in #118960.

Related: #108977
Related: #118111
Related: #118960


Workflow [PR]
Sync PR [sync-upstream/pr/112313]

In `S3Queue`/`AzureQueue`, when `ObjectStorageQueueIFileMetadata::trySetProcessing`
fails because the `processing` node in keeper already exists, it belongs to
another processor - another server, or another table on this server. The local
`FileStatus` was then updated to `Processing` and, because the two
non-processable checks in `trySetProcessing` and `prepareSetProcessingRequests`
treat `Processing` as terminal, every later attempt short-circuited on that
cached state without ever rechecking keeper.

Unlike `Processed` and `Failed`, `Processing` is not backed by a persistent
keeper node: the foreign processor can release the file without committing it
(it can die, or fail the file and reset the node). Stale `processing` node
cleanup does not evict `local_file_statuses` either - only the processed/failed
node cleanup does. So this table kept skipping such a file until the file status
was evicted from the cache or the server was restarted.

The cached `Processing` state is now remembered as a hint: it still shows up in
`system.s3queue`, but it no longer makes the file non-processable, so the file
is picked up again as soon as the foreign `processing` node is gone. As soon as
the foreign processor commits the file, the next attempt fails on the
`processed` (or `failed`) node instead and the state becomes terminal again, so
this costs at most one extra keeper request per listing pass for a contended
file.

Follow-up of #108977, where this
was found during review: the regression test there has to accept losing one
file for exactly this reason.
@clickhouse-gh

clickhouse-gh Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [24fed79]

Summary: ⏳

job_name test_name status info comment
Stateless tests (arm_binary, ParallelReplicas, plan-based, s3 storage, parallel) FAIL
05182_compress_per_substream_in_compact_parts FAIL cidb
04836_time_series_v10_selector_whole_metric_pk_range NOT_FAILED cidb
04891_timeseries_lowcardinality_id NOT_FAILED cidb
05137_join_fixed_string_zero_bytes_runtime_filter NOT_FAILED cidb
05234_promql_result_timestamp_scale NOT_FAILED cidb
05293_promql_constant_scalar_arithmetic NOT_FAILED cidb
05399_autopr_plan_without_parallel_replicas NOT_FAILED cidb
01710_projection_with_mixed_pipeline NOT_FAILED cidb
05033_lazy_materialization_column_function_structure_equals NOT_FAILED cidb
05076_promql_label_manipulation_label_names NOT_FAILED cidb
19 more test cases not shown

AI Review

Summary

The PR prevents ordered S3Queue/AzureQueue ingestion from advancing past foreign-held files, adds bounded retries and replay barriers, and reconciles cached terminal states with Keeper. One new allocation-failure path leaves the retry queue invalid and can cause a null dereference, so approval is blocked.

Findings

❌ Blockers

  • ObjectStorageQueueSource.cpp:833–836: takeDueForeignProcessingRechecks must preserve valid pending entries on exceptions. After the first object is moved into the local batch, a later allocation failure destroys that batch but leaves a null object in the persistent deque. The exception precedes the filter's invalidation guard, and the non-bucket path retains the iterator. getRecheckDeadline then dereferences the null entry at line 858. The extracted C++ method reproduced this state in both unordered and ordered mode. Make the queue and replay-barrier transfer transactional, or discard the damaged iterator safely and relist the unprocessed prefix.
Tests
  • ⚠️ Add focused allocation-failure coverage after the first retry has moved, verifying that subsequent deadline calculation and iteration remain safe and ordered files are eventually ingested. The existing hand-off failpoint covers a different transfer. The standalone probe validates the damaged queue state with stubbed metadata; it does not run a ClickHouse server.
  • The latest Praktika report reports no failed tests. Server tests were not rerun in this review job.
Final Verdict

Status: ❌ Block

Make retry-batch extraction exception-safe and add focused recovery coverage. Inline finding.

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jul 28, 2026
@kssenii kssenii self-assigned this Jul 29, 2026
…meout and keep a local `Processing` state

Two changes from the review of #112313:

- Per kssenii's suggestion, respect the cached `Processing` state of a foreign
  `processing` node until a timeout, storing the observation time in the cached
  `FileStatus`. The file is skipped without keeper probes while the observation
  is fresh, and is probed again (refreshing the observation) after the timeout,
  so a file released without a commit is retried within the timeout instead of
  being probed on every polling pass.

- Per the AI review, `afterSetProcessing` no longer flips a locally-owned
  `Processing` state to "processing by another processor": when a same-server
  contender (the `FileStatus` is shared between tables using the same keeper
  path, and between insert threads) loses the race to a local processor, the
  local state is kept and its owner updates it on commit.

Co-Authored-By: Claude Fable 5 <[email protected]>
Covers the same-server contention case requested by the AI review:
a contender which loses the race for the `processing` node to a concurrent
local processor sharing the same `FileStatus` must not relabel the
locally-owned `Processing` state as "processing by another processor".
Also covers caching the foreign observation as non-terminal and clearing
the hint on real state transitions.

Co-Authored-By: Claude Fable 5 <[email protected]>
…g and reset stale attempt data

- The timeout for which an observation of a `processing` node of another processor is
  trusted is now a table setting, `foreign_processing_node_cache_ttl_seconds`, with the
  default of 5 minutes instead of the previous hardcoded 30 seconds (review by kssenii).
- `onProcessingByAnotherProcessor` resets the per-attempt fields of the previous local
  attempt (`processed_rows`, `processing_end_time`, `last_exception`) and keeps `retries`,
  so that `system.s3queue_metadata_cache` does not show a `Processing` file with the
  failure data of a previous local attempt (review by `clickhouse-gh`).
- The state is now represented by a single timestamp instead of a timestamp and a flag:
  this keeps `sizeof(FileStatus)` in the range asserted by
  `test_5.py::test_metadata_cache_exact_size_tracking`, which the previous commit broke.
- Comments are shortened, as requested in the review.
@alexey-milovidov
alexey-milovidov requested a review from a team as a code owner August 1, 2026 12:22
@mintlify

mintlify Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
ClickHouse-docs 🟢 Ready View Preview Nov 25, 2026, 5:32 AM

@alexey-milovidov

Copy link
Copy Markdown
Member Author

🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=112313&sha=a238b9531b5a8ca0be9939116151a416126e74a3&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29 and provide a fix in a separate PR. If the fix is already in progress, link it here.

It is Logical error: 'Got read request from replica 1 for unknown stream <db>.<inner_id...>' in ParallelReplicasReadingCoordinator::handleRequest (src/Storages/MergeTree/ParallelReplicasReadingCoordinator.cpp:1295), followed by Server died. It is unrelated to this PR (which only touches ObjectStorageQueue). The previous auto-generated tracking issue for this assertion, #110518 (STID: 5217-5b3d), was closed on 2026-07-31, but the same assertion reappeared here with STID: 5217-505b and has no open issue.

@groeneai

groeneai commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

The fix is already merged: #111689 ("Fix unknown-stream LOGICAL_ERROR in parallel replicas with projection short-circuit"), merged 2026-07-31T15:40:01Z as f4f2c33. It closed #110518 automatically, which is why that issue went to CLOSED/COMPLETED at 15:40:02Z: the closure was the fix landing, not a premature triage.

STID 5217-505b is not a distinct defect. Both suffixes are the same throw at ParallelReplicasReadingCoordinator.cpp:1295; they differ only in which RemoteSource path delivered the follower's packet. The STID suffix hashes the top 5 DB:: frames below the exception (ci/jobs/scripts/log_parser.py, get_stack_trace_id), so a different delivery path yields a different hash for the same bug. Feeding the two observed frame sets through that function reproduces both suffixes exactly:

  • handleRequest <- processMergeTreeReadTaskRequest <- processPacket <- readAsync <- RemoteSource::tryGenerate -> 5217-505b
  • handleRequest <- processMergeTreeReadTaskRequest <- processPacket <- processParallelReplicaPacketIfAny <- RemoteSource::onAsyncJobReady -> 5217-5b3d

That is why no separate issue exists for 505b: it is #110518's bug reaching the coordinator through the sync rather than the async source path. Both suffixes also interleave across the same builds in CIDB over the past two weeks, which a genuinely separate defect would not do.

The failure you linked predates the fix. Your build a238b953 was committed 2026-07-31T12:23:54Z, about 66 minutes before f4f2c33 merged, and the fix's code is absent from that tree: neither the parallel_replicas_skip_aggregate_projection_on_follower fail point nor the announce* calls in optimizeUseAggregateProjection.cpp / optimizeUseNormalProjection.cpp are there. I checked every 5217-* hit recorded after the merge timestamp (6 of them, across PRs 103182, 110733, 112756, 112313, 111834, 96662): all six ran on builds that predate the fix. There is no hit on any build containing it.

Since then the last 5217-* hit fleet-wide was 2026-07-31T18:58:19Z, and Stateless tests (amd_llvm_coverage, ParallelReplicas, s3 storage, parallel) has run on 198 distinct builds with zero recurrences. Before the fix that job hit this assertion 14-35 times a day.

So no separate PR is needed, and nothing is needed on this PR either: your current head 8ed76ea already contains f4f2c33, so the assertion cannot fire on it. I will keep watching CIDB and open a specifically-titled issue if it reappears on a build that does contain the fix.

@clickhouse-gh

clickhouse-gh Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.50% 86.50% +0.00%
Functions 91.90% 91.90% +0.00%
Branches 78.70% 78.70% +0.00%

Changed lines: Changed C/C++ lines covered: 162/162 (100.00%) · Uncovered code

Full report · Diff report

… `system.s3_queue_settings`

`StorageObjectStorageQueue::getSettings` reconstructs the queue settings,
and it did not restore the new TTL, so `system.s3_queue_settings` always
reported the default `300` regardless of the configured value.
Add `ObjectStorageQueueMetadata::getForeignProcessingNodeCacheTTLSeconds`
and use it in `getSettings`; the integration test now checks the reported value.

Also move the documentation of the setting from the generated
`docs/reference/engines/table-engines/integrations/s3queue.mdx` into the
embedded `Documentation` block in `registerQueueStorage.cpp`, which is the
source the page is generated from - direct edits to the generated page are
rejected by the "No direct edits to generated or read-only docs" check.
…can run it

`Bugfix validation (unit tests)` builds a "before" binary from the merge-base
with only the PR's unit-test files overlaid, and reports a compile failure as
inconclusive. The gtest referenced symbols that exist only in this branch
(`isProcessingByAnotherProcessor`, `isProcessingRetryable`, and the new
constructor parameter), so the "before" binary could never be built.

Assert the behavior through the API that already exists on the merge-base:
observing a foreign `processing` node drops the data of the previous local
attempt, while a locally owned `Processing` state keeps it. That is a real
reproduction - the first test fails without the fix - and it still covers the
same-server contention case and the clearing of the foreign-processing hint.
The timeout behavior is covered by the integration test.

For this the new constructor parameter `foreign_processing_node_cache_ttl_sec_`
is moved to the last position with the default of zero (always check keeper),
so the constructor stays source-compatible with the merge-base.
…r-table setting

`ObjectStorageQueueMetadataFactory` shares one `ObjectStorageQueueMetadata`
between all tables with the same `keeper_path`, so the TTL kept in that shared
object was silently fixed by the table created first, both for the retry window
and for what `system.s3_queue_settings` reported. The value now travels from
`StorageObjectStorageQueue` through `FileIterator` to `getFileMetadata`, so
every table uses the value from its own DDL.

Also, as requested in the review, `onProcessingByAnotherProcessor` now calls
`onProcessing` instead of repeating it, and `isProcessingRetryable` is renamed
to `shouldRetryProcessing`.

A new integration test creates two tables sharing one `keeper_path` with
different values of the setting and checks both the reported value and the
retry window.
alexey-milovidov and others added 2 commits October 30, 2026 05:54
…pointer only for cached records

With `after_processing = 'keep'`, ordered `AzureQueue` and partitioned `S3Queue`
relist the whole retained processed history on each pass. Reading a `failed` node for
each of these files sent keeper work proportional to the history on every pass, while
the terminal state of a file without a cached `FileStatus` is not used anyway.
Now the `failed` node of a file covered by the processed pointer is read only when the
file has a cached record to reconcile (the cache is bounded), keeping `Failed` precedence
over the processed pointer for `system.s3queue_metadata_cache`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-processing-node-cache

Resolve the conflict in `StorageObjectStorageSource::createReader`: keep both
master's new `prefetch_input_format` parameter and this PR's
`iterator_consumed` parameter (in that order), and pass
`prefetch_input_format = false` explicitly from `ObjectStorageQueueSource`
so the pointer is not implicitly converted to `bool`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-processing-node-cache

Resolved the conflict in `test_metadata_cache_exact_size_tracking`: keep the PR's upper bound
(400, the PR adds atomics to `FileStatus`) and take master's comment about string capacity rounding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Common/FailPoint.cpp
clickhouse-gh[bot]
clickhouse-gh Bot previously approved these changes Nov 18, 2026
alexey-milovidov and others added 2 commits November 20, 2026 00:59
# Conflicts:
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.h
#	src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp
The `arm_tidy` build failed with `modernize-use-nodiscard` on
`isSetProcessingContended`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh
clickhouse-gh Bot dismissed their stale review November 20, 2026 01:38

AI review of a later commit does not approve the PR, see the AI Review comment.

alexey-milovidov and others added 2 commits November 22, 2026 15:10
A file handed out by the `S3Queue` file iterator in `ordered` mode is an
"unresolved set-processing" barrier of its ordering domain until the
outcome of its claim is recorded somewhere else: as a foreign-held file,
as a blocked file, or as a pending replay. Recording it allocates, so it
can throw (e.g. `MEMORY_LIMIT_EXCEEDED`), and the hand-off was not
exception-safe:

- `recheckForeignProcessingLater` removed the unresolved barrier before
  `recordForeignHeldFile`. If the latter threw, the file was tracked
  nowhere, and a later file of the domain could be committed past it,
  losing it once the foreign processor released it without a commit.
- `waitOrderingDomainGate` moved the object into `rememberBlockedFile` /
  `deferBehindReplay` before removing its barrier. If that threw, the
  barrier stayed registered with no owner, so the later files of the
  domain and `isFinished` waited forever.

Now the barrier is always removed last, after the outcome is recorded,
and every hand-off in `FileIterator::next` is guarded by
`abandonOrderingBarrierHandOff`: it first blocks the rest of the listing
pass (the state already used when the ordering barriers overflow:
nothing more is handed out, nothing is inherited, the next pass lists
everything again in order) and only then removes the orphaned barrier.
Merely erasing the barrier would reopen the data-loss path. A failure to
register the barrier of a file just taken from the listing invalidates
the iterator, as a failure in `filterProcessableFiles` does.

The failpoint `object_storage_queue_fail_ordering_barrier_hand_off` and
`test_files_are_not_lost_after_ordering_barrier_hand_off_failure` cover
the first case.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@stresshouse

stresshouse Bot commented Nov 22, 2026

Copy link
Copy Markdown

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 29 queries analysed

no significant changes detected. K_source=4 K_base=30 flagged=0/65

clickbench

🟢 No significant changes

tpch_adapted_1_official

🟢 No significant changes

Debug info
  • StressHouse run: 19a904ee-2b70-498e-9680-855dc7a77d47
  • MIRAI run: 818c70e8-9b93-4922-8dd4-e00e4e0fce9c
  • PR check IDs:
    • clickbench_826676_1795370170
    • clickbench_826682_1795370170
    • tpch_adapted_1_official_826717_1795370170
    • tpch_adapted_1_official_826739_1795370171

alexey-milovidov and others added 2 commits November 25, 2026 05:24
…urce`

- `abandonOrderingBarrierHandOff`: the `catch (...)` which clears all the
  unresolved set-processing barriers swallowed the exception silently
  (`catch_all` in the style check). Log it with `tryLogCurrentException`.
- `OrderingDomainGate gate` was declared without an initializer
  (`cppcoreguidelines-init-variables` in the `arm_tidy` build). It is always
  assigned before use, the initializer only satisfies the check.

https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112313&sha=25ba4261267c985e371b80f49d89d5375d6dab68&name_0=PR&name_1=Style%20check
https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=112313&sha=25ba4261267c985e371b80f49d89d5375d6dab68&name_0=PR&name_1=Build%20(arm_tidy%2C%201%2F4)
#112313

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Comment on lines +833 to +836
due.push_back(std::move(pending.object));
}
else
remaining.push_back(std::move(pending));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Blocker] Keep retry-queue entries valid when batch extraction throws

pending.object is moved out of the persistent deque before the whole transfer succeeds. With two expired rechecks, the first due.push_back can succeed and the second can throw std::bad_alloc; unwinding destroys due, but the original deque still contains the first entry with a null object. Replay bookkeeping can also be partially transferred.

This happens before the filterProcessableFiles exception guard in next. In unordered mode, and in ordered mode with buckets = 1, the iterator is retained after the exception. The next deadline calculation dereferences that null entry in getRecheckDeadline at line 858, so a recoverable allocation failure becomes undefined behavior. An allocation-failure probe using the current extracted method reproduced a null entry in the retained three-entry queue in both modes.

Please make batch extraction transactional, including its replay barriers, or discard the damaged iterator and its pending entries before it can be consulted again, preserving ordered relisting of the unprocessed prefix. Cover a failure after the first object has been transferred; the new claim hand-off failpoint does not exercise this path.

This branch was successfully deployed

1 active deployment
staging - docs — 24fed799 Deployed Nov 25, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-s3queue S3Queue/AzureQueue engines (queue-based ingestion from object storage). pr-bugfix Pull request with bugfix, not backported by default

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants