Skip to content

Conversation

@ppigazzini
Copy link
Collaborator

@ppigazzini ppigazzini commented Apr 4, 2024

Python 3.12 introduced a bug during the interpreter shutdown, see:

With Python 3.12.3, this change could potentially be reverted (after testing).

@ppigazzini ppigazzini added bug server server side changes labels Apr 4, 2024
@ppigazzini ppigazzini force-pushed the race_flush_all_buffers branch from 4993f0e to b86b1aa Compare April 4, 2024 16:28
@ppigazzini ppigazzini marked this pull request as draft April 4, 2024 16:42
@ppigazzini
Copy link
Collaborator Author

ppigazzini commented Apr 4, 2024

Drafting, python 3.12 intentionally blocked the spawn of a new thread during the shutdown process, I found the official issue upstream (VanRossum involved!):
python/cpython#113964

EDIT: The fix for the RuntimeError issue has already been merged upstream. You can find the relevant pull request here below. With the release of Python 3.12.3, this error should no longer occur.
python/cpython#117029

@ppigazzini ppigazzini force-pushed the race_flush_all_buffers branch from b86b1aa to 0b7cc2a Compare April 4, 2024 16:47
@ppigazzini
Copy link
Collaborator Author

ppigazzini commented Apr 4, 2024

For reference this is the strack trace in the log on DEV + few workers triggered with:

clear && sudo systemctl restart fishtest@{6543..6545} && sudo journalctl -u fishtest@6543 --since "10 minutes ago"
systemd[1]: Stopping Fishtest Server port 6543...
pserve[17032]: flush
pserve[17032]: .....................done
pserve[17032]: Exception in thread Thread-740:
pserve[17032]: Traceback (most recent call last):
pserve[17032]:   File "/home/fishtest/.pyenv/versions/3.12.2/lib/python3.12/threading.py", line 1073, in _bootstrap_inner
pserve[17032]:     self.run()
pserve[17032]:   File "/home/fishtest/.pyenv/versions/3.12.2/lib/python3.12/threading.py", line 1431, in run
pserve[17032]:     self.function(*self.args, **self.kwargs)
pserve[17032]:   File "/home/fishtest/fishtest/server/fishtest/rundb.py", line 451, in flush_buffers
pserve[17032]:     self.start_timer()
pserve[17032]:   File "/home/fishtest/fishtest/server/fishtest/rundb.py", line 365, in start_timer
pserve[17032]:     self.timer.start()
pserve[17032]:   File "/home/fishtest/.pyenv/versions/3.12.2/lib/python3.12/threading.py", line 992, in start
pserve[17032]:     _start_new_thread(self._bootstrap, ())
pserve[17032]: RuntimeError: can't create new thread at interpreter shutdown
systemd[1]: Stopped Fishtest Server port 6543.

Python 3.12 introduced a bug during the interpreter shutdown, see:
- issue python/cpython#104826
- bugfix python/cpython#117029

With Python 3.12.3, this change could potentially be reverted (after testing).
@ppigazzini ppigazzini force-pushed the race_flush_all_buffers branch from 0b7cc2a to a24b9d4 Compare April 4, 2024 18:34
@ppigazzini ppigazzini changed the title Mitigate Shutdown RuntimeError Mitigate Python 3.12 Shutdown RuntimeError Apr 4, 2024
@ppigazzini ppigazzini added the update code change to account external change (Stockfish, book etc.) label Apr 4, 2024
@ppigazzini ppigazzini marked this pull request as ready for review April 4, 2024 18:38
@ppigazzini ppigazzini merged commit c8173d2 into official-stockfish:master Apr 4, 2024
@ppigazzini ppigazzini deleted the race_flush_all_buffers branch April 4, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug server server side changes update code change to account external change (Stockfish, book etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant