-
Notifications
You must be signed in to change notification settings - Fork 510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid callmemaybe #117
Comments
Notes from conversations with @kelvich: End goalThe full goal of this issue comes in two parts. The first is to replace the existing communication between postgres and safekeeper so that it's built entirely on libpq, using a new libpq command for safekeeper that postgres calls: Current implementation(Note: I may have some pieces of this somewhat wrong -- please let me know!) The current communications between safekeeper and postgres are done outside of the postgres protocol, directly over TCP with a custom protocol. The safekeeper initiates the communication as a request for postgres to forward the WAL to it, but safekeeper must ask. There's a similar mechanism at play in safekeeper <-> pageserver and postgres <-> pageserver connections -- I don't yet know enough about that to precisely say what distinguishes it from the postgres <-> safekeeper connection though. The protocol in use is essentially just sending along the WAL, but there's a few extra pieces of information that it gets tagged with for handling elections, so we can't just directly use the relevant functionality from the postgres protocol. Desired implementationWhat we want to do is to switch over the existing custom protocol (built on top of TCP), and fit that to work over ReasoningBriefly: "callmemaybe" carries unnecessary complexity -- especially because it's currently implemented outside of the postgres protocol. Implementing the functionality as "pushing" the WAL instead of "pulling" would be simpler, and building it on top of the postgres protocol allows us to take full advantage of the systems already provided there (like authentication). |
Thanks for writing this up. small fix:
(from 'Current implementation') Postgres initiates communication with safekeeper. That is opposed to how that happens with pg<->pageserver and safekeeper<->pageserver where initiating party should first connect and run 'callmemaybe' and after that receiving party would open connection to the initiator and start pulling WAL. |
I spent some time earlier trying to understand how walproposer fits into the postgres codebase in order to know what actually needs to change -- the end result is the picture of a flowchart I drew up below. For the most part, arrows correspond to function calls. Somtimes, little additional notes are included - like indicating that There's more stuff within walproposer that I didn't cover here, but I found the overall system view to be helpful enough by itself to polish up a little and add to the issue. |
Hi, what is the current state of this task? Am I right to understand that the idea of this issue is to replace this exact code with our PostgresBackend connection and custom WalReceiverHandler implementation of postgres_backend::Handler ? |
@arssher is on it. But we will anyway keep current logic too, as it allows us to provision new pageservers. |
Corresponding PR is #628 |
Here are my final thoughts on this one:
All in all, feels like a big refactoring to me; a lot of unsymmetrical logic and connection state machines are already in place. |
Right now postgres and safekeeper need to call pageserver command "callmemaybe" to ask for incoming WAL streaming connection. Also there is a postgres <-> safekeeper connection that can be initiated without any callbacks. We can switch to that protocol both in postgres <-> pageserver direct connection and in safekeeper <-> pageserver connection.
The text was updated successfully, but these errors were encountered: