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

sampling/pubsub: minor fixes #5568

Merged
merged 3 commits into from
Jun 30, 2021
Merged

sampling/pubsub: minor fixes #5568

merged 3 commits into from
Jun 30, 2021

Conversation

axw
Copy link
Member

@axw axw commented Jun 29, 2021

Motivation/summary

Revise the pubsub API so that the PublishSampledTraceIDs method is long-lived and accepts a channel of trace IDs. This brings PublishSampledTraceIDs closer to the API of SubscribeSampledTraceIDs, and ensures we properly close the BulkIndexer used by the publisher when it exits.

Also, fix a race in the pubsub tests. We now write HTTP response from the handler goroutine rather than in another goroutine which waits for the request. This avoids a race in the existing test code, where the client receives the response and closes the connection, causing the server's handler context to be cancelled before the handler returns.

Related issues

Closes #5493
Closes #5480

axw added 2 commits June 29, 2021 20:51
Revise the pubsub API so that the PublishSampledTraceIDs
method is long-lived and accepts a channel of trace IDs;
this brings it closer to the API of SubscribeSampledTraceIDs,
and ensures we properly close the BulkIndexer used by the
publisher when it exits.
Write HTTP response from the handler goroutine,
rather than in another goroutine which waits for
the request. This avoids a race in the existing
test code, where the client receives the response
and closes the connection, causing the server's
handler context to be cancelled before the handler
returns.
@axw axw added the v7.14.0 label Jun 29, 2021
@apmmachine
Copy link
Contributor

apmmachine commented Jun 29, 2021

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Build Cause: Pull request #5568 updated

  • Start Time: 2021-06-30T00:36:28.642+0000

  • Duration: 37 min 36 sec

  • Commit: b9f7185

Test stats 🧪

Test Results
Failed 0
Passed 5887
Skipped 109
Total 5996

Trends 🧪

Image of Build Times

Image of Tests

@axw axw requested a review from a team June 29, 2021 13:32
Copy link
Contributor

@simitt simitt left a comment

Choose a reason for hiding this comment

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

Changes look good.

@axw axw merged commit 0a985aa into elastic:master Jun 30, 2021
@axw axw deleted the pubsub-close branch June 30, 2021 09:26
mergify bot pushed a commit that referenced this pull request Jun 30, 2021
* sampling/pubsub: close BulkIndexer

Revise the pubsub API so that the PublishSampledTraceIDs
method is long-lived and accepts a channel of trace IDs;
this brings it closer to the API of SubscribeSampledTraceIDs,
and ensures we properly close the BulkIndexer used by the
publisher when it exits.

* sampling/pubsub: fix double WriteHeader in test

Write HTTP response from the handler goroutine,
rather than in another goroutine which waits for
the request. This avoids a race in the existing
test code, where the client receives the response
and closes the connection, causing the server's
handler context to be cancelled before the handler
returns.

(cherry picked from commit 0a985aa)
axw added a commit that referenced this pull request Jun 30, 2021
* sampling/pubsub: close BulkIndexer

Revise the pubsub API so that the PublishSampledTraceIDs
method is long-lived and accepts a channel of trace IDs;
this brings it closer to the API of SubscribeSampledTraceIDs,
and ensures we properly close the BulkIndexer used by the
publisher when it exits.

* sampling/pubsub: fix double WriteHeader in test

Write HTTP response from the handler goroutine,
rather than in another goroutine which waits for
the request. This avoids a race in the existing
test code, where the client receives the response
and closes the connection, causing the server's
handler context to be cancelled before the handler
returns.

(cherry picked from commit 0a985aa)

Co-authored-by: Andrew Wilkins <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pubsub: Pubsub offers no Close method for closing BulkIndexer Data race in pub/sub implementation
3 participants