Skip to content

[Test] Fix log after client close#548

Open
zhanglistar wants to merge 4 commits intoapache:mainfrom
bigo-sg:fix-logging-after-client-close-issue-530
Open

[Test] Fix log after client close#548
zhanglistar wants to merge 4 commits intoapache:mainfrom
bigo-sg:fix-logging-after-client-close-issue-530

Conversation

@zhanglistar
Copy link
Contributor

Fixes #530

Motivation

When Python/C++ bindings create C++ ProducerImpl/ConsumerImpl objects and the Python interpreter shuts down, C++ destructors may run after the client is already closed.
This causes logging attempts during static/global cleanup which is dangerous because logging systems might already be torn down. Issue #530 identified this problem: "We
should not print logs after client is closed".

Modifications

  1. Changed ProducerImpl::printStats() from LOG_INFO to LOG_DEBUG
  2. Added client existence checks in ProducerImpl destructor before logging warnings
  3. Added client existence checks in ConsumerImpl destructor before logging warnings
  4. Downgraded ConsumerImpl race condition closure log from INFO to DEBUG
  5. When client is already destroyed, log at DEBUG level instead of WARN

Verifying this change

  • Make sure that the change passes the CI checks.

This change is already covered by existing tests, such as ProducerTest and ConsumerTest which exercise producer/consumer lifecycle.

Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

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

This still print debug logs, which checks the Logger::isEnabled after the client is closed. Technically, we should not access the logger after the client is closed.

zhangzhibiao added 2 commits March 10, 2026 08:34
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.

We should not print logs after client is closed

2 participants