Skip to content

Make client smarter about Spring server state#756

Merged
rafaelfranca merged 1 commit into
rails:mainfrom
Korri:spring-client-smart-retry
Jun 9, 2026
Merged

Make client smarter about Spring server state#756
rafaelfranca merged 1 commit into
rails:mainfrom
Korri:spring-client-smart-retry

Conversation

@Korri

@Korri Korri commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

This covers two ways a client can find an existing Spring socket but still fail the initial version handshake:

  • another client booted the server first, and the server is still busy preloading the app before it can accept this client
    • ➡️ now we retry with timeout: Spring.boot_timeout.
  • the previous server died after leaving its socket/pidfile on disk
    • ➡️ now we check for the existence of the process, and start a new one if it's not there.

Before this, both could surface as “Error connecting to Spring server” even though the right behavior is recoverable: wait a little longer for the live booting server, or restart when the old server is gone.

The retry is still bounded. If the pidfile lock says a server is alive, a client that did not boot it gets one boot_timeout-sized wait for the greeting. If this client already booted the server, or the extra wait still does not produce a greeting, we keep failing/restarting instead of looping forever.

I added acceptance coverage with real Spring processes for both cases, including a probe that proves the second client actually took the boot-timeout path.

@rafaelfranca

Copy link
Copy Markdown
Member

Tests are failing with a timeout. Can you take a look?

@Korri Korri force-pushed the spring-client-smart-retry branch from b435b15 to e9f5140 Compare June 8, 2026 13:59
Add the ability for a second Spring client to connect to the server
socket while the first client is still preloading the app, by retrying
with an increased timeout when that situation is detected.

Also handle the case where we have a PID file, but no corresponding
server socket.
@Korri Korri force-pushed the spring-client-smart-retry branch from e9f5140 to c8b3fce Compare June 8, 2026 17:20
@Korri

Korri commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Tests are failing with a timeout. Can you take a look?

@rafaelfranca should be good now, the new tests had some leakage.

@rafaelfranca rafaelfranca merged commit 368fc24 into rails:main Jun 9, 2026
28 checks passed
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