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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ ISegment StartMessageBrokerSegment(MethodCall methodCall, MessageBrokerDestinati
/// <summary>
/// Detatches the transaction from each non-async active context storage. This is necessary when async tracking needs to continue but
/// the primary context(s) the transaction may be stored can continue to persist, such as thread static or thread local storgage.
/// <para>
/// <b>Warning:</b> This method should only be called at the start of the transaction, before any other segments are created.
/// If called partway through the transaction, this can result in "Transaction was garbage collected without ever ending" errors.
/// </para>
/// </summary>
void DetachFromPrimary();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall ins
if (isAsync)
{
transaction.AttachToAsync();
transaction.DetachFromPrimary(); //Remove from thread-local type storage
}

// Get the IRequestContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall ins
if (instrumentedMethodCall.IsAsync)
{
transaction.AttachToAsync();
transaction.DetachFromPrimary(); //Remove from thread-local type storage
}

dynamic invokeModelRequest = instrumentedMethodCall.MethodCall.MethodArguments[0];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ public AfterWrappedMethodDelegate BeforeWrappedMethod(InstrumentedMethodCall ins
if (isAsync)
{
transaction.AttachToAsync();
transaction.DetachFromPrimary(); //Remove from thread-local type storage

var parameterTypeNamesList = instrumentedMethodCall.InstrumentedMethodInfo.Method.ParameterTypeNames.Split(',');
if (parameterTypeNamesList[4] == "Elasticsearch.Net.IRequestParameters")
{
Expand Down
Loading