Skip to content

refactor(concurrency): replace arc-swap with standard locks - #26359

Draft
pront wants to merge 2 commits into
masterfrom
pront-remove-arc-swap
Draft

pront wants to merge 2 commits into
masterfrom
pront-remove-arc-swap

Conversation

@pront

@pront pront commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Motivation

Vector uses arc-swap for several read-heavy snapshots, but there is no evidence that a standard lock is insufficient for these paths. Keeping the specialized synchronization primitive as a direct dependency adds complexity before it is justified by measurements.

Changes

  • Replace the TLS acceptor, enrichment table, VRL metrics, and EC2 metadata snapshots with Mutex<Arc<T>>.
  • Hold each lock only long enough to clone or replace the shared snapshot.
  • Remove Vector's direct arc-swap declarations and update the concurrency guidance.

References

Vector configuration

N/A

How did you test this PR?

Ran the focused TLS certificate rotation, enrichment reload, VRL metrics, and EC2 metadata tests. CI covers the remaining validation.

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.

Contributor Guidelines

  • Please read our Vector contributor resources.
  • Do not hesitate to use @vectordotdev/vector to reach out to us regarding this PR.
  • Before pushing, follow our pre-push guidance.
  • After a review is requested, please avoid force pushes to help us review incrementally.
    • Feel free to push as many commits as you want. They will be squashed into one before merging.
    • For example, you can run git merge origin master and git push.

@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: transforms Anything related to Vector's transform components domain: core Anything related to core crates i.e. vector-core, core-common, etc labels Sep 11, 2026
@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Sep 11, 2026
@pront
pront marked this pull request as ready for review September 11, 2026 16:35
@pront
pront requested review from a team as code owners September 11, 2026 16:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 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-09-11T17:14:05.041097Z df99085 New commits
ℹ️ 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: a8b279c5ce

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread lib/vector-vrl/enrichment/src/tables.rs Outdated

@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: df99085e1e

ℹ️ 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".

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

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

/// Replace the cached metrics. Exposed for the VRL test crate.
#[doc(hidden)]
pub fn set_metrics(&self, metrics: Arc<[Metric]>) {
*self.cache.lock().unwrap_or_else(PoisonError::into_inner) = metrics;

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 Release the lock before dropping the old metrics snapshot

When metrics_storage_refresh_period is enabled and no query still retains the previous Arc, this assignment destroys the entire old metrics slice while holding cache's mutex. A large internal-metrics snapshot can contain many heap-backed names, tags, and metadata values, so every concurrent get_vector_metric, find_vector_metrics, or aggregate_vector_metrics call will be blocked during that deallocation. Use mem::replace to move the old Arc out and drop it after the mutex guard has been released.

Useful? React with 👍 / 👎.

@pront
pront marked this pull request as draft September 11, 2026 17:17
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: core Anything related to core crates i.e. vector-core, core-common, etc domain: transforms Anything related to Vector's transform components no-changelog Changes in this PR do not need user-facing explanations in the release changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant