Skip to content

fix: don't buffer client request before checking maintenance mode#1259

Open
levkk wants to merge 1 commit into
mainfrom
levkk-move-maint-mode-up
Open

fix: don't buffer client request before checking maintenance mode#1259
levkk wants to merge 1 commit into
mainfrom
levkk-move-maint-mode-up

Conversation

@levkk

@levkk levkk commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

@codecov

codecov Bot commented Jul 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Comment on lines +598 to +599
// This will pause the client until the maintenance mode is off
// without checking any timeouts or reading data off of the socket

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.

the buffer future is created once during select! in loop and in order to it to be recreated we should proceed to the next iteration of the loop.

that means we can get the following flow:

  1. client connects and stays idle
  2. no maintenance mode so we don't wait and go straight to buffer read
  3. we enable maintenance
  4. the idle client runs some command and we execute them without checks for maintenance

yes, other branches in select! could recreate the future, but that's not reliable.

So, moving the check upfront could it make it worse, because the check actually moved to the connection time whilst previously it was at execution time, when we actually got some commands.

I think we really need integration tests here to verify the behavior.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Oh wow. That's such a footgun...really good catch.

Comment on lines +600 to +601
// so if the client disconnects while we wait, we won't send
// its pending query to the database.

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 guess the socket data will still be in the kernel buffer and we'll still read and try to execute as soon as we read proper spliced part. The query will be executed then and we'll probably get an error when we write.

that's why another pr for the issue was trying to always read the stream to catch the EOF to understand if the client is disconnected during maintenance.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I see that now.

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.

[Query engine] maintenance mode should not allow queries from disconnected clients

2 participants