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

Request additional sync point on discard. #584

Merged
merged 3 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docker/prep_stmts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pstst
psmst
Binary file removed docker/prep_stmts/pstst
Binary file not shown.
1 change: 1 addition & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ set(od_src
deploy.c
reset.c
frontend.c
backend_sync.c
backend.c
instance.c
main.c
Expand Down
34 changes: 34 additions & 0 deletions sources/backend_sync.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Odyssey.
*
* Scalable PostgreSQL connection pooler.
*/

#include <kiwi.h>
#include <machinarium.h>
#include <odyssey.h>

int od_backend_request_sync_point(od_server_t *server)
{
od_instance_t *instance = server->global->instance;
int rc;

machine_msg_t *msg;
msg = kiwi_fe_write_sync(NULL);
if (msg == NULL) {
return -1;
}
rc = od_write(&server->io, msg);
if (rc == -1) {
od_error(&instance->logger, "sync-point", server->client,
server, "write error: %s", od_io_error(&server->io));
return NOT_OK_RESPONSE;
}

/* update server sync state */
od_server_sync_request(server, 1);

return od_backend_ready_wait(server, "sync-point", 1 /*count*/,
UINT32_MAX /* timeout */,
0 /*ignore error?*/);
}
12 changes: 12 additions & 0 deletions sources/backend_sync.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef ODYSSEY_BACKEND_SYNC_H
#define ODYSSEY_BACKEND_SYNC_H

/*
* Odyssey.
*
* Scalable PostgreSQL connection pooler.
*/

int od_backend_request_sync_point(od_server_t *);

#endif /* ODYSSEY_BACKEND_SYNC_H */
15 changes: 15 additions & 0 deletions sources/reset.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ int od_reset(od_server_t *server)
assert(od_server_synchronized(server));
break;
}

/* Request one more sync point here.
* In `od_server_synchronized` we
* count number of sync/query msg send to connection
* and number of RFQ received, if this numbers are equal,
* we decide server connection as sync. However, this might be
* not true, if client-server relay advanced some extended proto
* msgs without sync. To safely execute discard queries, we need to
* advadance sync point first.
*/

if (od_backend_request_sync_point(server) == NOT_OK_RESPONSE) {
goto error;
}

od_debug(&instance->logger, "reset", server->client, server,
"synchronized");

Expand Down
Loading