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

Reorder the destructor of members in LoggerProvider and TracerProvider #1245

Merged

Conversation

owent
Copy link
Member

@owent owent commented Mar 4, 2022

…r. It's safe to shutdown multiple times.(Fix #1244)

Signed-off-by: owentou [email protected]

Fixes #1244

Changes

  1. Reorder the destructor of members in LoggerProvider and TracerProvider.
  2. It's safe to shutdown multiple times.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Unit tests have been added
  • Changes in public API reviewed

@owent owent requested a review from a team March 4, 2022 16:04
@codecov
Copy link

codecov bot commented Mar 4, 2022

Codecov Report

Merging #1245 (67963f1) into main (cba0a2a) will increase coverage by 0.03%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1245      +/-   ##
==========================================
+ Coverage   92.29%   92.31%   +0.03%     
==========================================
  Files         198      198              
  Lines        7273     7281       +8     
==========================================
+ Hits         6712     6721       +9     
+ Misses        561      560       -1     
Impacted Files Coverage Δ
ext/test/http/curl_http_test.cc 95.17% <100.00%> (ø)
sdk/src/trace/batch_span_processor.cc 93.03% <100.00%> (+1.36%) ⬆️
sdk/src/trace/tracer_provider.cc 76.75% <100.00%> (+2.39%) ⬆️
sdk/test/trace/batch_span_processor_test.cc 100.00% <100.00%> (ø)
sdk/test/trace/tracer_provider_test.cc 100.00% <100.00%> (ø)

@owent
Copy link
Member Author

owent commented Mar 4, 2022

It's too late on my timezone. I will solve the failed jobs tomorrow.

Copy link
Member

@esigo esigo left a comment

Choose a reason for hiding this comment

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

LGTM
Thanks for the PR.

@owent owent force-pushed the fix_crash_when_destroying_tracer branch from d9792f5 to 3b54c24 Compare March 7, 2022 02:16
@esigo
Copy link
Member

esigo commented Mar 7, 2022

@owent could you please rebase?

std::unique_ptr<instrumentationlibrary::InstrumentationLibrary> instrumentation_library_;
std::shared_ptr<LoggerContext> context_;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is cyclic dependency still an issue here as it changes weak_ptr to shared_ptr?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no cyclic dependency right now.It's only be hold in Logger and LoggerProvider and Logger is only hold by LoggerProvider.

}

// Should only shutdown exporter ONCE.
if (!already_shutdown && exporter_ != nullptr)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is showing down is going, later call to Shutdown will just return true even if the previous Shutdown has not been completed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes and thanks, it's definitely a problem.I add a mutex lock to prevent this.

owent and others added 8 commits March 8, 2022 09:57
…r. It's safe to shutdown multiple times.(Fix open-telemetry#1244)

Signed-off-by: owentou <[email protected]>
…comparison of integer expressions of different signedness: 'int' and 'const long unsigned int' [-Wsign-compare]`

Signed-off-by: owentou <[email protected]>
Signed-off-by: owentou <[email protected]>
+ Temporary fix the `Export()` may be called too many times when we shutdown or just wakeup worker thread once.This problem is completely fixed in open-telemetry#1209 but not merged yet.
+ Fix http client may has a different error code when our network is under a proxy.
@owent owent force-pushed the fix_crash_when_destroying_tracer branch from 3b54c24 to 67963f1 Compare March 8, 2022 02:23
@owent
Copy link
Member Author

owent commented Mar 8, 2022

@owent could you please rebase?

Done

@ThomsonTan ThomsonTan changed the title Reorder the destructor of members in LoggerProvider and TracerProvide… Reorder the destructor of members in LoggerProvider and TracerProvider Mar 8, 2022
@ThomsonTan ThomsonTan merged commit c96a3e3 into open-telemetry:main Mar 8, 2022
@owent owent deleted the fix_crash_when_destroying_tracer branch March 9, 2022 06:58
@lalitb lalitb mentioned this pull request Mar 22, 2022
3 tasks
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.

Crash when destroy LoggerProvider and TracerProvider
4 participants