alda-lang / alda

A music programming language for musicians. :notes:
https://alda.io
Eclipse Public License 2.0
5.62k stars 289 forks source link

Alda REPL server sometimes "claims" more than 1 player on startup #416

Open daveyarwood opened 2 years ago

daveyarwood commented 2 years ago

🐞 Bug report 🐞

Description

When starting an Alda REPL session, the REPL server finds an available player process (i.e. one in the "ready" state) and "claims" it by sending it a ping message. This puts the player process into the "active" state, which makes Alda more eager to spawn new player processes in order to have them readily available.

This works reliably, but it seems to be a little too reliable in that, for some reason, two player processes seem to go from "ready" to "active" when the REPL server starts.

Steps to Reproduce

  1. In a separate terminal, monitor the state of the player processes by running watch alda ps.
  2. Start from a clean state by running alda shutdown to shut down all current player processes.
  3. Run alda -v2 repl to start a REPL session in verbose mode.
  4. Exit the session and start a new one.
  5. Repeat step 4.

Expected Behavior

Each time a REPL session is started, only 1 of the players in the "ready" state goes into the "active" state.

Alda spawns more player processes as needed, but it shouldn't need to do that too much, because only one process becomes unavailable for each REPL session.

Actual Behavior

The first time I start a REPL server session, I see 5 players in the "ready" state and 1 player in the "active" state. The REPL server output shows that it is using the 1 player in the "active" state.

When I exit that session and start another one, 2 of the players that were in the "ready" state go into the "active" state. One of them is the one that this new REPL session is using. We are now down to 3 players in the "ready" state.

If I keep going, exiting and starting new REPL sessions, more and more player processes are spawned to ensure that there are always player processes available in the "ready" state.

Environment

Operating system and version: Ubuntu 20.04

Alda version:

$ alda version
alda 2.2.1
$ alda-player info
alda-player 2.2.1
log path: /home/dave/.cache/alda/logs

Health check:

$ alda doctor
(all passing)