Skip to content

Commit

Permalink
[walproposer] Async WAL append (#105)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petuhovskiy authored and tristan957 committed Feb 5, 2024
1 parent 136db80 commit 533678a
Show file tree
Hide file tree
Showing 4 changed files with 230 additions and 189 deletions.
9 changes: 2 additions & 7 deletions src/backend/replication/libpqwalproposer/libpqwalproposer.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static WalProposerConnectPollStatusType libpqprop_connect_poll(WalProposerConn*
static bool libpqprop_send_query(WalProposerConn* conn, char* query);
static WalProposerExecStatusType libpqprop_get_query_result(WalProposerConn* conn);
static pgsocket libpqprop_socket(WalProposerConn* conn);
static int libpqprop_flush(WalProposerConn* conn, bool socket_read_ready);
static int libpqprop_flush(WalProposerConn* conn);
static void libpqprop_finish(WalProposerConn* conn);
static PGAsyncReadResult libpqprop_async_read(WalProposerConn* conn, char** buf, int* amount);
static PGAsyncWriteResult libpqprop_async_write(WalProposerConn* conn, void const* buf, size_t size);
Expand Down Expand Up @@ -239,13 +239,8 @@ libpqprop_socket(WalProposerConn* conn)
}

static int
libpqprop_flush(WalProposerConn* conn, bool socket_read_ready)
libpqprop_flush(WalProposerConn* conn)
{
/* If the socket is read-ready, we have to call PQconsumeInput before
* calling PQflush (according to libpq docs) */
if (socket_read_ready && !PQconsumeInput(conn->pg_conn))
return -1; /* return failure if PQconsumeInput fails */

return (PQflush(conn->pg_conn));
}

Expand Down
Loading

0 comments on commit 533678a

Please sign in to comment.