Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(internal/otelarrow) Add new LIFO boundedqueue #36140

Merged
merged 10 commits into from
Nov 12, 2024

Conversation

jmacd
Copy link
Contributor

@jmacd jmacd commented Nov 1, 2024

Description

Adds a new LIFO-based bounded queue implementation for use by OTel-Arrow receiver admission control logic. This code is similar to but different than the existing bounded queue implementation. This code fixes a race condition discovered in the original package, which occurs when the admission is granted concurrently with context cancellation. This code is extracted from #36033, which demonstrates a final-state solution to #36074 and has been broken into parts to make reviews easier.

There are two substantial changes in this bounded queue implementation, although they appear similar. Because the differences between the old and new are relatively meaningless, and because the overall change is large, this PR proposes to add a new library of code that will not be used until a future PR.

The two substantial changes are:

  • LIFO semantics instead of FIFO
  • Infallible API pattern.

In addition, this fixes a race in the FIFO queue: when a task is canceled concurrently with being admitted, the resource will leak.

Because the changes were so significant, I chose to start from scratch with testing. The replacement tests have 100% coverage and are fairly readable.

After this merges, the residual portion of #36033 will be a small change. In addition, by taking this approach we can close #36100 because #36033 will have been reduced to a small change that only replaces waiter_limit with waiting_limit_mib.

Link to tracking issue

Part of #36074.

Testing

New tests have 100% coverage.

Documentation

README added.

@jmacd jmacd requested a review from a team as a code owner November 1, 2024 19:08
@jmacd jmacd requested a review from andrzej-stencel November 1, 2024 19:08
@github-actions github-actions bot requested a review from moh-osman3 November 1, 2024 19:09
@jmacd
Copy link
Contributor Author

jmacd commented Nov 1, 2024

The residual portion of #36033 is now drafted in #36141. It is a fairly small change. @andrzej-stencel let me know if this approach sounds good to you.

For that PR to pass its tests, the contents of this PR would be merged first. Then, the old admission package would be delated, and the new admission2 package would be renamed admission.

Copy link
Contributor

@moh-osman3 moh-osman3 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link

@lquerel lquerel left a comment

Choose a reason for hiding this comment

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

I made a few suggestions to potentially reduce contention on the lock.

Copy link

@lquerel lquerel left a comment

Choose a reason for hiding this comment

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

Thanks for creating the GH issue open-telemetry/otel-arrow#270 for tracking.

LGTM.

@jmacd jmacd added the Skip Changelog PRs that do not require a CHANGELOG.md entry label Nov 7, 2024
@jmacd
Copy link
Contributor Author

jmacd commented Nov 7, 2024

No changelog is needed, the next step #36141 where we use this code will have a user-relevant changelog.

@djaglowski djaglowski merged commit 6eece9b into open-telemetry:main Nov 12, 2024
158 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 12, 2024
@jmacd jmacd deleted the jmacd/newboundedqueue branch November 12, 2024 16:55
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal/otelarrow Skip Changelog PRs that do not require a CHANGELOG.md entry
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants