Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

proxy request if replication has not started #719

Merged
merged 1 commit into from
Oct 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sqld/src/connection/write_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ impl Connection for WriteProxyConnection {
replication_index: Option<FrameNo>,
) -> Result<(B, State)> {
let mut state = self.state.lock().await;
if *state == State::Init && pgm.is_read_only() {

// This is a fresh namespace, and it is not replicated yet, proxy the first request.
if self.applied_frame_no_receiver.borrow().is_none() {
self.execute_remote(pgm, &mut state, auth, builder).await
} else if *state == State::Init && pgm.is_read_only() {
self.wait_replication_sync(replication_index).await?;
// We know that this program won't perform any writes. We attempt to run it on the
// replica. If it leaves an open transaction, then this program is an interactive
Expand Down