Skip to content

feat(topology): add opt-in reload sink drain limit - #26834

Open
thomasqueirozb wants to merge 1 commit into
remove-windows-reload-sleepfrom
reload-sink-drain-limit
Open

thomasqueirozb wants to merge 1 commit into
remove-windows-reload-sleepfrom
reload-sink-drain-limit

Conversation

@thomasqueirozb

Copy link
Copy Markdown
Member

Summary

Add --reload-sink-drain-limit-secs (VECTOR_RELOAD_SINK_DRAIN_LIMIT_SECS) so that a sink that does not stop cannot block a configuration reload. All removed and changed sinks share one deadline. The flag is unset by default, and --graceful-shutdown-limit-secs does not apply to reloads.

Sinks during a reload Current (default, flag unset) New (flag set)
Changed sink that reuses its buffer Reload waits until the sink stops and can block indefinitely Sink is cancelled at the deadline. The replacement receives unread events. In-flight events are lost
Sink with a resource conflict, or changed sink with a new disk buffer Reload waits until the sink stops and can block indefinitely Sink is cancelled at the deadline. In-flight events are lost
Other removed or changed sinks Sink drains its buffer in the background. Reload does not wait Sink is cancelled at the deadline. Unread and in-flight events are lost
Disk buffers Records are acknowledged after the sink finishes them Records in flight at the deadline are acknowledged and deleted from disk
End-to-end acknowledgements Source acknowledges after delivery Events lost at the deadline still report Delivered, so the source acknowledges them upstream

The data loss is opt-in and documented in the flag help. A follow-up PR will mark in-flight events as Errored when a sink is cancelled, so sources with acknowledgements retry them instead of acknowledging lost data.

References

Depends on: #26832
Related: #26793

Vector configuration

sources:
  in:
    type: demo_logs
    format: shuffle
    lines: ["before"]
    interval: 0.2
sinks:
  out:
    type: console
    inputs: [in]
    encoding:
      codec: text

How did you test this PR?

  • Unit tests in topology::running::tests: the deadline is shared and unread events move to the replacement; without the flag, the shutdown grace period does not cancel a stalled sink.
  • Ran vector --reload-sink-drain-limit-secs 5 with the config above, changed the codec to json, and sent SIGHUP. The reload finished and output switched to JSON. --reload-sink-drain-limit-secs 0 is rejected.

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the no-changelog label to this PR.

@github-actions github-actions Bot added docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain:topology Anything related to Vector's topology code domain:external docs Anything related to Vector's external, public documentation labels Oct 23, 2026
@thomasqueirozb
thomasqueirozb marked this pull request as ready for review October 23, 2026 20:50
@thomasqueirozb
thomasqueirozb requested review from a team as code owners October 23, 2026 20:51
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T20:56:19.625134Z 379217b Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 379217b1ca

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/cli.rs
Comment on lines +266 to +267
/// events. Other unread and in-flight events are lost. If not set, Vector waits until the
/// sinks finish.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Describe background sink draining accurately

When the option is unset, a reload does not wait for every removed sink: shutdown_diff explicitly drops the task handle for sinks outside wait_for_sinks, allowing them to drain in the background while the reload continues (src/topology/running.rs:718-724). This help text, also repeated in the changelog and generated CLI reference, therefore misstates the existing behavior; describe the unset case as having no cancellation deadline, with only resource-conflicting or buffer-reusing sinks awaited.

Useful? React with 👍 / 👎.

Comment thread src/topology/running.rs
Comment on lines +661 to +663
let deadline = self
.reload_sink_drain_duration
.map(|limit| Instant::now() + limit);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Reject drain limits that overflow Instant

When --reload-sink-drain-limit-secs or its environment variable is set to a sufficiently large nonzero u64 (for example 18446744073709551615), clap accepts it as NonZeroU64, but the first sink-changing reload panics here because adding that duration to Instant::now() overflows. Validate the CLI value or use checked_add so an accepted setting cannot crash Vector during reload.

Useful? React with 👍 / 👎.

@datadoghq-integration datadoghq-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bits Code Review: FAIL

Deadline cancellation can leave spawned requests holding a disk-buffer lock. For affected sinks, changing disk-buffer settings can then fail both replacement and rollback, shutting Vector down instead of completing the reload.

Open Bits AI session

🤖 Bits Code Review · Commit 379217b

Comment thread src/topology/builder.rs
() = reload_deadline => {
warn!("Sink did not finish before the reload deadline. Cancelling in-flight work.");
// Drop only the sink future, retaining unread buffered events for its replacement.
Ok(())

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Cancel spawned requests before reporting sink shutdown

With the drain limit enabled, changing disk-buffer settings for an influxdb_logs or gcp_pubsub sink while a request remains pending beyond the deadline can terminate Vector. PartitionBatchSink spawns request tasks that survive dropping sink.run. Their event finalizers keep the disk ledger’s buffer.lock held, so both the replacement and rollback fail to open the same buffer, triggering FailedToRestore and shutdown. Cancel and await spawned requests before reporting the sink stopped; this requires changes beyond this cancellation branch.

React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it

What each reaction means
  • 👍 Useful: correct, and you're fixing it or will.
  • 👎 Wrong: the finding is incorrect, for example the bug can't happen or the code was misread.
  • 😕 Unclear: you can't tell what it means or why it matters.
  • 👀 Right, not acting: correct, but intended, out of scope for this PR, a known risk, or too minor.

🤖 Bits Code Review · Open Bits AI session

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs review on hold The documentation team reviews PRs only after a PR is approved by the COSE team. domain:external docs Anything related to Vector's external, public documentation domain:topology Anything related to Vector's topology code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant