-
Notifications
You must be signed in to change notification settings - Fork 599
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
Bugfix Thread instrumentation continuing to use finished transactions on other threads #1969
Conversation
finished transaction
used in new threads
SimpleCov Report
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Memory copying for new threads can be tricky. I'm very glad to see you were able to get this addressed in such a clear way that doesn't risk adverse side effects.
@@ -29,6 +29,12 @@ def add_segment(segment, parent = nil) | |||
else | |||
segment.record_on_finish = true | |||
::NewRelic::Agent.logger.debug("Segment limit of #{segment_limit} reached, ceasing collection.") | |||
|
|||
if finished? | |||
::NewRelic::Agent.logger.debug("Transaction #{best_name} has finished but segments still being created, resetting state.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new module code make use of a method, best_name
, that doesn't exist in the module, so the code can only be used by an instance of the Transaction
class. Seeing as the Transaction
class is the only consumer (includer) of this Tracing
module, this is probably ok.
The NewRelic::Agent::PipeChannelManagerTest has two cases failing on Ruby 2.5.9 and Rails 6.0/6.1: #test_listener_merges_error_events, #test_listener_merges_error_traces These tests started failing after PR#1969 was merged: #1969 The tests are now skipped in the specific conditions where they intermittently fail
This fixes a bug where the agent would continue to record segments on transactions that were already finished in another thread. This would lead to increased memory usage over time because the agent would continue to copy over the finished transaction as the still current transaction in the thread instrumentation, causing the agent to think it was still supposed to continue recording data on the actually finished transaction. Now the agent will check the finished state of a transaction before using it when a new thread is spawned.
Additionally, if a transaction reaches the segment limit but the transaction is actually already finished on some other thread, the state will now reset, preventing future segments from being created and a supportability metric will be recorded.
#1936