Skip to content

improvement: commit + log + metric on task failure in GC and lifecycle cold-archive#2771

Open
delthas wants to merge 1 commit into
development/9.5from
improvement/BB-772/commit-on-poison-pill
Open

improvement: commit + log + metric on task failure in GC and lifecycle cold-archive#2771
delthas wants to merge 1 commit into
development/9.5from
improvement/BB-772/commit-on-poison-pill

Conversation

@delthas

@delthas delthas commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

TL;DR — Two task error paths (GC's _deleteArchivedSourceData and lifecycle's cold-status archive) currently return { committable: false } after their retry budget is exhausted, without ever calling onEntryCommittable. The offset never advances past those entries, they linger in the OffsetLedger, and with the BB-777 rebalance-wait-for-drain fix now merged this turns every rebalance that catches one into a forced pod restart. This PR flips those sites to commit on final failure, adds a structured error log at the point of drop, and adds a per-extension counter so operators can alert on the rate.

What "final failure" means here

Both sites are wrapped by a BackbeatTask.retry-style helper with a ~5 minute budget and exponential backoff — they only reach the poison-pill path once retries are exhausted or the error is flagged non-retryable. Realistic triggers include:

  • a warm cluster / metadata service / vault outage lasting longer than the retry budget
  • non-retryable backend errors (e.g. AccessDenied after a role rotation, version conflicts)
  • the lifecycle orphan-cleanup path failing to publish because the cold producer can't reach its target topic

Why not "kafka will redeliver"

That was the intent behind committable: false, but it doesn't work: Kafka only redelivers on the next assignment (rebalance / restart), and neither path benefits from an upstream cron. The cold-status message is a one-shot notification from the cold backend; the GC deleteArchivedSourceData entry is published exactly once by the archive task in fire-and-forget mode. On top of that, LifecycleTask explicitly skips objects with transitionInProgress=true on later bucket scans, so the regular pipeline won't pick a stuck object back up either. Effectively the current behavior is "hold the offset forever, ledger grows, and next rebalance forces a pod restart."

What this PR does

For each of the two sites:

  1. Stop returning { committable: false } — just call done(err) so the consumer commits the offset like it would for any other completed task.
  2. At the outer retry-wrapper's completion callback (i.e. the point where the retry gave up), emit an error-level log with the entry info, the error message, and whether the error was retryable.
  3. Increment a new counter recording the failure so operators can alert on it:
    • s3_gc_failed_total{origin, location, retryable} for GC
    • s3_lifecycle_failed_total{origin, type, location, retryable} for lifecycle

The log + metric live at the retry-wrapper's completion callback (not inside the task's own error handler) so they fire exactly once per final give-up, not once per attempt.

The retryable label is a boolean, matching the existing precedent from OplogPopulatorMetrics.connectorConfigurationApplied's success label — prom-client stringifies to "true" / "false".

For GC, the pre-existing ObjNotFound / NoSuchBucket carveout (return with commit, no retry) is simplified from done(err, { committable: true }) to done(err) — same semantics, less noise.

What this PR does not do

  • Does not introduce a retry topic, dead-letter topic, or sweeper. That's a follow-up design conversation (see BB-772 slack context). The consequence of this PR is that permanent failures are now visible as an error log + a metric datapoint rather than a silent ledger leak, but the underlying operation is not retried automatically.
  • Does not change the behavior of Pattern A callers (ReplicateObject, MultipleBackendTask, CopyLocationTask, LifecycleUpdateTransitionTask) that use committable: false correctly with a producer-callback onEntryCommittable.

Issue: BB-772

@bert-e

bert-e commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Hello delthas,

My role is to assist you with the merge of this
pull request. Please type @bert-e help to get information
on this process, or consult the user documentation.

Available options
name description privileged authored
/after_pull_request Wait for the given pull request id to be merged before continuing with the current one.
/bypass_author_approval Bypass the pull request author's approval
/bypass_build_status Bypass the build and test status
/bypass_commit_size Bypass the check on the size of the changeset TBA
/bypass_incompatible_branch Bypass the check on the source branch prefix
/bypass_jira_check Bypass the Jira issue check
/bypass_peer_approval Bypass the pull request peers' approval
/bypass_leader_approval Bypass the pull request leaders' approval
/approve Instruct Bert-E that the author has approved the pull request. ✍️
/create_pull_requests Allow the creation of integration pull requests.
/create_integration_branches Allow the creation of integration branches.
/no_octopus Prevent Wall-E from doing any octopus merge and use multiple consecutive merge instead
/unanimity Change review acceptance criteria from one reviewer at least to all reviewers
/wait Instruct Bert-E not to run until further notice.
Available commands
name description privileged
/help Print Bert-E's manual in the pull request.
/status Print Bert-E's current status in the pull request TBA
/clear Remove all comments from Bert-E from the history TBA
/retry Re-start a fresh build TBA
/build Re-start a fresh build TBA
/force_reset Delete integration branches & pull requests, and restart merge process from the beginning.
/reset Try to remove integration branches unless there are commits on them which do not appear on the source branch.

Status report is not available.

@scality scality deleted a comment from bert-e Jul 6, 2026
@bert-e

bert-e commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Waiting for approval

The following approvals are needed before I can proceed with the merge:

  • the author

  • 2 peers

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.59259% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.31%. Comparing base (295fa38) to head (8051dd1).

Files with missing lines Patch % Lines
extensions/gc/GarbageCollectorMetrics.js 80.00% 1 Missing ⚠️
extensions/lifecycle/LifecycleMetrics.js 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

Files with missing lines Coverage Δ
extensions/gc/tasks/GarbageCollectorTask.js 88.00% <100.00%> (+0.71%) ⬆️
...ectProcessor/LifecycleObjectTransitionProcessor.js 70.83% <100.00%> (+20.08%) ⬆️
.../lifecycle/tasks/LifecycleColdStatusArchiveTask.js 91.83% <100.00%> (+2.04%) ⬆️
extensions/gc/GarbageCollectorMetrics.js 90.90% <80.00%> (-3.21%) ⬇️
extensions/lifecycle/LifecycleMetrics.js 97.05% <75.00%> (-0.91%) ⬇️

... and 5 files with indirect coverage changes

Components Coverage Δ
Bucket Notification 80.22% <ø> (ø)
Core Library 81.05% <ø> (-0.58%) ⬇️
Ingestion 70.13% <ø> (ø)
Lifecycle 80.27% <92.59%> (+0.55%) ⬆️
Oplog Populator 85.83% <ø> (ø)
Replication 61.56% <ø> (ø)
Bucket Scanner 85.76% <ø> (ø)
@@                 Coverage Diff                 @@
##           development/9.5    #2771      +/-   ##
===================================================
- Coverage            75.42%   75.31%   -0.11%     
===================================================
  Files                  201      201              
  Lines                13868    13889      +21     
===================================================
+ Hits                 10460    10461       +1     
- Misses                3398     3418      +20     
  Partials                10       10              
Flag Coverage Δ
api:retry 9.07% <0.00%> (-0.02%) ⬇️
api:routes 8.85% <0.00%> (-0.02%) ⬇️
bucket-scanner 85.76% <ø> (ø)
ft_test:queuepopulator 9.20% <3.70%> (-1.80%) ⬇️
ingestion 12.28% <0.00%> (-0.02%) ⬇️
lib 7.79% <0.00%> (-0.01%) ⬇️
lifecycle 19.17% <3.70%> (-0.03%) ⬇️
notification 1.00% <0.00%> (-0.01%) ⬇️
oplogPopulator 0.13% <0.00%> (-0.01%) ⬇️
replication 18.71% <3.70%> (-0.03%) ⬇️
unit 53.94% <92.59%> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@delthas delthas marked this pull request as ready for review July 6, 2026 11:11
gcFailed.inc({
[GC_LABEL_ORIGIN]: process,
[GC_LABEL_LOCATION]: location,
[GC_LABEL_RETRYABLE]: retryable === true,

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.

is retryable really relevant here?
the metric will only be called if we exhausted the retries anyway, and details will only be in the logs...

Suggested change
[GC_LABEL_RETRYABLE]: retryable === true,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The label distinguishes two operationally distinct failure modes that both land at this metric:

  • retryable=true — retries genuinely exhausted after ~5 min (backend outage). BackbeatTask.retry only enters the retry loop when shouldRetryFunc(err) returns truthy, so this path corresponds to "we tried and gave up."
  • retryable=false — the error was never retryable to begin with, so BackbeatTask.retry short-circuits on the first attempt (BackbeatTask.js:79-81) without any retry. Common triggers: AccessDenied after a role rotation, InvalidRequest/Conflict from cloudserver, errors.InternalError from arsenal when a client cannot be obtained, kafka producer send errors.

Same counter without the label conflates "backend was down for 5 minutes" (expected transient) with "we did not even try because the state was inconsistent" (config/auth problem). The two need different alert thresholds.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Grounded this by tracing through the actual code + deps. Concrete non-retryable cases in production (each fires the metric with retryable=false on the first attempt, no retry):

  • Cloudserver 5xx / 4xx — cloudserverclient is built on smithy/AWS SDK v3 (ServiceException at @smithy/smithy-client/dist-es/exceptions.js:1-12). It uses $retryable (with $ prefix), not the bare retryable that BackbeatTask.retry reads. err.retryable stays undefined. Concrete instances:

    • 500 internal error, 503 unavailable, 429 throttling — all $fault: "server"|"client", err.retryable=undefined
    • 403 AccessDenied (after role rotation, bucket policy tightening)
    • 400 InvalidRequest / InvalidArgument
    • 409 Conflict (version race on putMetadata between _getMetadata and _putMetadata)
  • arsenal.errors.InternalError — arsenal ArsenalError (arsenal/lib/errors/index.ts) has no retryable field. Fires from:

    • _getMetadata:47-51, _batchDeleteData:125-128, _putMetadata:88-92 when getBackbeatMetadataProxy(accountId) returns null (vault-derived client unavailable — vault down, bad account, IAM misconfig)
    • _getMetadata:69-75 when ObjectMD.createFromBlob(blob.Body) returns res.error (corrupted metadata blob)
  • Kafka producer sendLifecycleColdStatusArchiveTask._deleteColdObject:66-77 orphan-cleanup path. node-rdkafka producer errors do not set retryable.

  • ECONNREFUSED — the auto-flag in BackbeatTask.js:67-77 matches only ECONNRESET/EPIPE/ETIMEDOUT in err.code (and TimeoutError by name). ECONNREFUSED is not in the list.

Retryable cases (auto-flagged, retried through the 5 min budget, retryable=true fires only after exhaustion):

  • Socket reset mid-flight (err.code === 'ECONNRESET') — most common
  • Broken pipe (EPIPE)
  • Node socket timeout (ETIMEDOUT)
  • Smithy TimeoutError name

Note: err.retryable = true is manually set in only two places in the whole codebase: ReplicateObject.js:544 for source-stream errors and FailedCRRConsumer.js:147. Nothing in GC or lifecycle paths sets it explicitly, so those tasks rely entirely on the auto-flag.

So the bucket split is real and quite skewed: retryable=true = "sustained node-socket flapping", retryable=false = "nearly everything else including HTTP 5xx." Different alert thresholds warranted.

Comment thread extensions/lifecycle/objectProcessor/LifecycleObjectTransitionProcessor.js Outdated
Comment on lines +203 to +204
labelNames: [LIFECYCLE_LABEL_ORIGIN, LIFECYCLE_LABEL_TYPE,
LIFECYCLE_LABEL_LOCATION, 'retryable'],

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.

same, I don't think the "retryable" label is useful

Suggested change
labelNames: [LIFECYCLE_LABEL_ORIGIN, LIFECYCLE_LABEL_TYPE,
LIFECYCLE_LABEL_LOCATION, 'retryable'],
labelNames: [
LIFECYCLE_LABEL_ORIGIN,
LIFECYCLE_LABEL_TYPE,
LIFECYCLE_LABEL_LOCATION,
],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The label distinguishes two operationally distinct failure modes that both land at this metric:

  • retryable=true — retries genuinely exhausted after ~5 min (backend outage). BackbeatTask.retry only enters the retry loop when shouldRetryFunc(err) returns truthy, so this path corresponds to "we tried and gave up."
  • retryable=false — the error was never retryable to begin with, so BackbeatTask.retry short-circuits on the first attempt (BackbeatTask.js:79-81) without any retry. Common triggers: AccessDenied after a role rotation, InvalidRequest/Conflict from cloudserver, errors.InternalError from arsenal when a client cannot be obtained, kafka producer send errors.

Same counter without the label conflates "backend was down for 5 minutes" (expected transient) with "we did not even try because the state was inconsistent" (config/auth problem). The two need different alert thresholds.

Comment thread extensions/gc/tasks/GarbageCollectorTask.js
}, done);
}, err => {
if (err && err.name !== 'ObjNotFound' && err.name !== 'NoSuchBucket') {
log.error('task failed permanently after retries, committing offset', {

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.

is error not logged already (in continuation callback) ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is overlap with BackbeatTask.retry's 'giving up processing as retries ended' (BackbeatTask.js:90), but only for the retryable-exhausted path. The non-retryable path skips the retry loop entirely (shouldRetryFunc(err) === falsedoneOnce(...args) at BackbeatTask.js:79-81) and never hits that message — without this new log, non-retryable failures would only leave per-step logs (batchDelete error, putMetadata error) with no task-level "we gave up" signal.

Comment thread extensions/gc/tasks/GarbageCollectorTask.js
@@ -310,7 +300,20 @@ class GarbageCollectorTask extends BackbeatTask {
actionFunc: cb => this._deleteArchivedSourceDataOnce(entry, log, cb),
shouldRetryFunc: err => err.retryable,

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.

what is the "retry budget" here?

we need to do something, but should we also increase this budget to ensure we don't just create orphans unexpectedly?
(note: we must increase the retry too much either, i.e. not go beyond Kafka's poll/rebalance deadlines : each task must still be processed within the expected time)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Current values: BackbeatTask.retry default timeoutS: 300 (5 min), backoff min 1s, max 5 min, factor 1.5, jitter 0.1. gcConfig.consumer.retry can override. On the lifecycle side, retryWrapper is set up from the same shape via the object-processor config.

Ceiling: the sum of retry attempts must stay under max.poll.interval.ms (~5 min default in librdkafka), otherwise a rebalance that catches an in-flight retry hits the BB-777 outer timeout (max.poll.interval - 1s) and forces a pod disconnect. Bumping the retry budget in isolation moves us closer to that boundary; a wider budget would need max.poll.interval widened in step.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think 5 min should be widely enough already. It would be pretty rare to have the system failing for 5 minutes but not 10. I'd say no change?

Comment thread tests/unit/gc/GarbageCollectorTask.spec.js Outdated
Comment thread tests/unit/gc/GarbageCollectorTask.spec.js Outdated
Comment thread extensions/gc/GarbageCollectorMetrics.js
…e cold-archive

Two error paths returned { committable: false } to the consumer after
their retry budget was exhausted, then never called onEntryCommittable.
The offset never advanced past these entries and they stayed in the
OffsetLedger indefinitely. With the BB-777 rebalance-wait-for-drain fix,
this now blocks every rebalance until the outer timeout fires and the
pod restarts, instead of just leaking memory.

Neither flow is retriggered by an upstream cron. The cold-status archive
is a one-shot notification from the cold backend, and LifecycleTask
skips objects with transitionInProgress=true on subsequent scans, so
there is no automatic recovery either way. There is also no dead-letter
mechanism today.

Step 1 is to stop pretending: commit the offset on permanent failure,
log an error message at the point where we drop the entry, and increase
a per-extension counter so operators can alert on it.

- GarbageCollectorTask._deleteArchivedSourceData: move the log + metric
  to the outer retry-wrapper's completion callback so it fires once per
  final give-up rather than per attempt. Simplify the ObjNotFound /
  NoSuchBucket carveout to done(err) (same semantics).
- GarbageCollectorTask._executeDeleteData: same treatment for the hot
  transition / restore-expiration paths (already committed on failure
  but silently).
- LifecycleObjectTransitionProcessor.processColdStorageStatusEntry:
  same idea, in the caller of retryWrapper.retry. Uses
  this.getProcessorType() rather than a hard-coded string.
- Add s3_gc_failed_total and s3_lifecycle_failed_total counters with
  origin / location / retryable labels (retryable boolean matches the
  precedent from OplogPopulatorMetrics.connectorConfigurationApplied).
- Add a "Task permanent failures" TimeSeries panel to the lifecycle
  dashboard's Lifecycle Tasks section, plotting both counters by
  type/origin + retryable.
- Unit tests: retry tests assert the metric fires with expected args;
  three new tests on LifecycleObjectTransitionProcessor cover the
  processor's failure metric under retryable=true / retryable=false /
  success. Fast retry backoff in the fixtures so they run in ms.

Issue: BB-772
@delthas delthas force-pushed the improvement/BB-772/commit-on-poison-pill branch from c7a81fb to 8051dd1 Compare July 10, 2026 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants