Skip to content
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

[walproposer] Async WAL append #105

Merged
merged 9 commits into from
Dec 21, 2021
Merged

[walproposer] Async WAL append #105

merged 9 commits into from
Dec 21, 2021

Conversation

petuhovskiy
Copy link
Member

@petuhovskiy petuhovskiy commented Dec 1, 2021

Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.

@@ -720,27 +727,14 @@ SendMessageToNode(int i, WalMessage *msg)
msg = msg->next;

wk->currMsg = msg;
wk->flushWrite = false;
wk->state = SS_ACTIVE;
Copy link

Choose a reason for hiding this comment

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

Let's move this to StartStreaming, as we need it only once

*/
wk->state = SS_SEND_WAL;
/* Don't ned to update the event set; that's done by AdvancePollState */
/* TODO: do we need to send messages immediately? */
Copy link

Choose a reason for hiding this comment

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

That's ok, we can convert comment to smth like 'Note: we always send everything to the safekeeper until WOULDBLOCK or nothing left to send'

wk->state = SS_IDLE;
UpdateEventSet(wk, WL_SOCKET_READABLE);
}
UpdateEventSet(wk, WL_SOCKET_READABLE | (wk->flushWrite ? WL_SOCKET_WRITEABLE : 0));
Copy link

Choose a reason for hiding this comment

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

Redundant? SendAppendRequests guts will set WL_SOCKET_WRITEABLE if needed.

* SendAppendRequests, but sent through a wire only with a flush in
* reading routine.
*/
while (wk->ackMsg != NULL && wk->ackMsg != wk->currMsg)
Copy link

@arssher arssher Dec 21, 2021

Choose a reason for hiding this comment

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

With this coding, if we don't wait for anything and connection is lost, we won't try reading from it and thus will never reset it, right? So better prepare to async responses right away and just expect here any ack message.

Also this 'sent with a flush in reading routine' shouldn't happen anymore...

On the second thought, it is not that bad as in case of any required action (data to send) connection reset will happen; better fix it right now, but I'm ok with doing it separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

'sent with a flush in reading routine' still can happen, it's in PQConsumeInput implementation: https://github.com/zenithdb/postgres/blob/main/src/interfaces/libpq/fe-exec.c#L1909-L1919

As we handle all read/write events and don't need to flush in PQConsumeInput, we may try to switch to using pqReadData instead. But for now we still can read responses ahead of requests, so I'd better create an issue for better async handling and fix it later.

@petuhovskiy petuhovskiy merged commit 22938e1 into main Dec 21, 2021
@petuhovskiy petuhovskiy deleted the append_ahead branch December 21, 2021 13:51
lubennikovaav pushed a commit that referenced this pull request Feb 9, 2022
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
MMeent pushed a commit that referenced this pull request Jul 7, 2022
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
MMeent pushed a commit that referenced this pull request Aug 18, 2022
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
lubennikovaav pushed a commit that referenced this pull request Nov 21, 2022
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
MMeent pushed a commit that referenced this pull request Feb 10, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
MMeent pushed a commit that referenced this pull request Feb 10, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
MMeent pushed a commit that referenced this pull request May 11, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Aug 10, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Nov 8, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Nov 8, 2023
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Feb 5, 2024
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Feb 5, 2024
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request Feb 6, 2024
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
tristan957 pushed a commit that referenced this pull request May 10, 2024
Implement async wp <-> sk protocol, send WAL messages ahead of feedback replies.

New SS_ACTIVE state is introduced instead of former SS_SEND_WAL / SS_SEND_WAL_FLUSH / SS_RECV_FEEDBACK.
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