Skip to content

Keep bisect log handlers isolated when instance IDs are reused - #439

Closed
FindHao wants to merge 1 commit into
mainfrom
export-D121418371
Closed

FindHao wants to merge 1 commit into
mainfrom
export-D121418371

Conversation

@FindHao

@FindHao FindHao commented Sep 23, 2026

Copy link
Copy Markdown
Member

Summary:
Creating a BisectLogger with a reused timestamp and object ID can retrieve a previous instance's logger from Python's global logging registry. Its closed handlers then reopen an old log file, mixing output between sessions or raising FileNotFoundError after the old temporary directory has been removed. This caused three setUp errors in GitHub Actions Tests #927: https://github.com/meta-pytorch/tritonparse/actions/runs/35882624122/job/107254643368

Give each BisectLogger its own logging.Logger and detach and close test handlers before removing temporary directories. Add a deterministic regression that forces object ID reuse and covers both retained and deleted previous log directories.

Differential Revision: D121418371

Summary:
Creating a BisectLogger with a reused timestamp and object ID can retrieve a previous instance's logger from Python's global logging registry. Its closed handlers then reopen an old log file, mixing output between sessions or raising FileNotFoundError after the old temporary directory has been removed. This caused three setUp errors in GitHub Actions Tests #927: https://github.com/meta-pytorch/tritonparse/actions/runs/35882624122/job/107254643368

Give each BisectLogger its own logging.Logger and detach and close test handlers before removing temporary directories. Add a deterministic regression that forces object ID reuse and covers both retained and deleted previous log directories.

Differential Revision: D121418371
Copilot AI lite review requested due to automatic review settings September 23, 2026 16:34
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 23, 2026
@meta-codesync

meta-codesync Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

@FindHao has exported this pull request. If you are a Meta employee, you can view the originating Diff in D121418371.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Initialize the isolated logger’s manager before any info() calls.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 1 High severity

Open (1)
What changed in this PR

This PR isolates BisectLogger instances and improves handler cleanup to prevent stale log reuse.

Changes:

  • Creates per-instance loggers.
  • Detaches handlers before temporary-directory cleanup.
  • Adds regression coverage for reused IDs and deleted log directories.
File Summary
tritonparse/​bisect/​logger.py Creates isolated logger instances; construction currently fails because the logger manager is unset.
tests/​cpu/​test_bisect_results.py Cleans up handlers before temporary directories.
tests/​cpu/​test_bisect_logger.py Adds ID-reuse regression coverage and cleanup helpers.
tests/​cpu/​test_bisect_executor.py Improves handler cleanup ordering.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +94 to 95
self.logger = logging.Logger(self._logger_name)
self.logger.setLevel(logging.DEBUG)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Directly constructed loggers inherit manager from the Logger class. The logging module initializes Logger.manager = Manager(Logger.root) at module scope (CPython 3.14 source). This class attribute is available even when the instance is not registered in manager.loggerDict, so isEnabledFor() can access self.manager.disable without an explicit manager assignment.

I verified the exported code at e94a395a68dcac1b782468c4f96a8e391db851b6 on Python 3.14.7: constructing BisectLogger(...) and calling info() both succeed, the message is written to the log file, and logger.manager is logging.root.manager is True. The reported AttributeError is therefore a false positive; an explicit manager assignment would just duplicate the inherited value.

@meta-codesync meta-codesync Bot closed this in 77e0ba4 Sep 23, 2026
@meta-codesync meta-codesync Bot added the Merged label Sep 23, 2026
@meta-codesync

meta-codesync Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

This pull request has been merged in 77e0ba4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. Merged meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants