Skip to content

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

Merged
geruh merged 2 commits intoapache:mainfrom
kevinjqliu:kevinjqliu/fix-test-3.13
May 3, 2026
Merged

fix: SaslServer busy-loop causes process hang after test suite#3305
geruh merged 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

Comment thread tests/catalog/test_hive.py
Comment thread tests/catalog/test_hive.py Outdated
Copy link
Copy Markdown
Member

@geruh geruh left a comment

Choose a reason for hiding this comment

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

LGTM!

@geruh geruh merged commit 842d01c into apache:main May 3, 2026
15 checks passed
self._socket.close()
except Exception:
pass
self.join(timeout=5)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nitty nit: we could add a warning/log here after the join if this thread is still alive.

@kevinjqliu kevinjqliu deleted the kevinjqliu/fix-test-3.13 branch May 3, 2026 19:54
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.

3 participants