Skip to content

Conversation

@drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Feb 7, 2025

I hereby agree to the terms of the CLA available at: https://docs.databend.com/dev/policies/cla/

Summary

chore: use Box::leak() to ensure logging guard lives for the program's lifetime

Previously, the logging guard was held with let _guard = ..., which
caused it to be dropped when the main function returned. This could
lead to an error when other threads, still running and depending on the
logging guard for log output, attempt to log after the guard has been
dropped.

By using Box::leak(), the logging guard is ensured to remain valid for
the entire lifetime of the program, preventing such errors.

Tests

  • Unit Test
  • Logic Test
  • Benchmark Test
  • No Test - Explain why

Type of change

  • Other

Related Issues


This change is Reviewable

@github-actions github-actions bot added the pr-chore this PR only has small changes that no need to record, like coding styles. label Feb 7, 2025
@drmingdrmer drmingdrmer changed the title chore: use Box::leak() to hold logging guard for the remainder of the program’s life. chore: use Box::leak() to ensure logging guard lives for the program's lifetime Feb 7, 2025
…m's lifetime

Previously, the logging guard was held with `let _guard = ...`, which
caused it to be dropped when the `main` function returned. This could
lead to an error when other threads, still running and depending on the
logging guard for log output, attempt to log after the guard has been
dropped.

By using `Box::leak()`, the logging guard is ensured to remain valid for
the entire lifetime of the program, preventing such errors.

- Fix: databendlabs#16676
@drmingdrmer drmingdrmer marked this pull request as ready for review February 7, 2025 15:33
@drmingdrmer drmingdrmer merged commit 5bd7525 into databendlabs:main Feb 8, 2025
71 of 73 checks passed
@drmingdrmer drmingdrmer deleted the 193-logging-scope branch February 8, 2025 01:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-chore this PR only has small changes that no need to record, like coding styles.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: Unknown "Error Perform Logging" errors often show up in databend meta.

1 participant