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

fix: Fix potential race condition in AWS SDK, AWS Bedrock, and Elastisearch that could lead to an orphaned Transaction. #2842

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

jaffinito
Copy link
Member

Description

Discovered that calling ITransaction.DetachFromPrimary when in the middle of a transaction can result in Transaction was garbage collected without ever ending errors due to the AsyncLocal context being forward only and the other contexts being cleared.

Removed the call from AWS SDK, AWS Bedrock, and Elastisearch instrumentation where the call was made in the middle of transaction. Left the method call in all other locations since it was done immediately after CreateTransaction was called.

Updated the summary for ITransaction.DetachFromPrimary to include a warning about this use case.

Author Checklist

  • Unit tests, Integration tests, and Unbounded tests completed
  • Performance testing completed with satisfactory results (if required)

Reviewer Checklist

  • Perform code review
  • Pull request was adequately tested (new/existing tests, performance tests)

@jaffinito jaffinito requested a review from a team as a code owner October 21, 2024 21:15
Copy link
Member

@chynesNR chynesNR left a comment

Choose a reason for hiding this comment

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

Good find! And a good reminder to be careful when copy-pasting from other wrappers. :)

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.31%. Comparing base (a77919e) to head (04e51a4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2842   +/-   ##
=======================================
  Coverage   81.31%   81.31%           
=======================================
  Files         460      460           
  Lines       29239    29239           
  Branches     3231     3231           
=======================================
  Hits        23777    23777           
  Misses       4669     4669           
  Partials      793      793           
Flag Coverage Δ
Agent 82.22% <ø> (ø)
Profiler 73.33% <ø> (ø)

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

see 2 files with indirect coverage changes

@nrcventura
Copy link
Member

We should probably brainstorm how we should describe this fix in the changelog, because the problem does not apply to all application types that use these libraries.

@jaffinito jaffinito changed the title fix: Fix Transaction was garbage collected errors in AWS SDK, AWS Bedrock, and Elastisearch. fix: Fix potential race condition in AWS SDK, AWS Bedrock, and Elastisearch that could lead to an orphaned Transaction. Oct 21, 2024
@jaffinito jaffinito merged commit 3afa15f into main Oct 21, 2024
94 checks passed
@jaffinito jaffinito deleted the fix/txn-garbage-collected-async-fix branch October 21, 2024 23:44
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