Skip to content

fix: SaslServer busy-loop causes process hang after test suite#3305

Open
kevinjqliu wants to merge 2 commits intoapache:mainfrom
kevinjqliu:kevinjqliu/fix-test-3.13
Open

fix: SaslServer busy-loop causes process hang after test suite#3305
kevinjqliu wants to merge 2 commits intoapache:mainfrom
kevinjqliu:kevinjqliu/fix-test-3.13

Conversation

@kevinjqliu
Copy link
Copy Markdown
Contributor

Rationale for this change

PYTHON=3.13 make test hangs after all tests pass.

The SaslServer test helper has except Exception: pass in its accept loop. After close() is called, accept() raises on every iteration but the exception is swallowed, creating a tight busy-loop that holds the GIL and prevents the process from exiting.

This is particularly severe on CPython 3.13+ on macOS, where GIL fairness changes make the main thread unable to make progress against the spinning daemon thread.

Changes

  • except Exception: pass -> except Exception: break to exit the loop when the socket is closed
  • Reorder close(): close the server socket first (unblocks accept()), then join() the thread (ensures no more client appends), then close tracked clients

Are these changes tested?

PYTHON=3.13 make test passes with clean exit.

Are there any user-facing changes?

No.

Co-authored-by: Copilot <copilot@github.com>
@kevinjqliu
Copy link
Copy Markdown
Contributor Author

not sure if im tripping, but this took me a while to figure out, and only affects python 3.13

Copy link
Copy Markdown
Contributor

@rambleraptor rambleraptor left a comment

Choose a reason for hiding this comment

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

This looks sensible. What a find! Thanks for doing this

except Exception:
pass
self._socket.close()
self.join(timeout=5)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have the feeling I know the answer, but why 5?

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.

just randomly picked a value, 5 seconds should be long enough for the threads to shutdown

Comment thread tests/catalog/test_hive.py Outdated
self._socket.close()
self.join(timeout=5)
for client in self._clients:
client.close()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should probably be in a try/except block again. If one of these throws an exception, it'll crash.

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.

ty, made the change!

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.

2 participants