Skip to content

Fix race in TCP publisher close() vs concurrent connect() (#69187)#69328

Open
dwoz wants to merge 2 commits into
saltstack:3007.xfrom
dwoz:fix/issue-69187
Open

Fix race in TCP publisher close() vs concurrent connect() (#69187)#69328
dwoz wants to merge 2 commits into
saltstack:3007.xfrom
dwoz:fix/issue-69187

Conversation

@dwoz

@dwoz dwoz commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Guards _connecting_future.set_result() / set_exception() against the future having been cleared by a concurrent close().

What issues does this PR fix or reference?

Fixes #69187

Previous Behavior

_TCPPubServerPublisher.close() sets self._connecting_future = None. If a concurrent _connect() coroutine was awaiting stream.connect(), the await resumes and calls .set_result(True) or .set_exception(e) on None, raising AttributeError: 'NoneType' object has no attribute 'set_result'.

New Behavior

Both call sites guard with if self._connecting_future is not None. The legacy salt.transport.ipc.IPCMessageClient in the original traceback was removed on master/3008.x; the same pattern persists in the replacement publisher, which this fixes.

Merge requirements satisfied?

  • Docs
  • Changelog
  • Tests written/updated

Commits signed with GPG?

Yes

@dwoz dwoz requested a review from a team as a code owner June 6, 2026 05:48
@dwoz dwoz added the test:full Run the full test suite label Jun 6, 2026
@dwoz dwoz added this to the Chlorine v3007.15 milestone Jun 6, 2026

@dwoz dwoz left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Please add a functional test that exercises this code path too.

@dwoz

dwoz commented Jun 7, 2026

Copy link
Copy Markdown
Contributor Author

Added functional test in tests/pytests/functional/transport/tcp/test_pub_server.py — drives publisher.connect()/close() through a real io_loop and bound TCP socket, only IOStream.connect is wrapped to deterministically park _connect() during the race. Fails on unfixed code with the exact AttributeError.

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

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant