diff --git a/docker/prep_stmts/.gitignore b/docker/prep_stmts/.gitignore new file mode 100644 index 000000000..666e094e2 --- /dev/null +++ b/docker/prep_stmts/.gitignore @@ -0,0 +1,2 @@ +pstst +psmst diff --git a/docker/prep_stmts/pstst b/docker/prep_stmts/pstst deleted file mode 100755 index 550577eab..000000000 Binary files a/docker/prep_stmts/pstst and /dev/null differ diff --git a/sources/CMakeLists.txt b/sources/CMakeLists.txt index 97ac47fd2..1089e2cb7 100644 --- a/sources/CMakeLists.txt +++ b/sources/CMakeLists.txt @@ -24,6 +24,7 @@ set(od_src deploy.c reset.c frontend.c + backend_sync.c backend.c instance.c main.c diff --git a/sources/backend_sync.c b/sources/backend_sync.c new file mode 100644 index 000000000..1a557c1b3 --- /dev/null +++ b/sources/backend_sync.c @@ -0,0 +1,34 @@ +/* + * Odyssey. + * + * Scalable PostgreSQL connection pooler. + */ + +#include +#include +#include + +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?*/); +} \ No newline at end of file diff --git a/sources/backend_sync.h b/sources/backend_sync.h new file mode 100644 index 000000000..b22665d8f --- /dev/null +++ b/sources/backend_sync.h @@ -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 */ diff --git a/sources/reset.c b/sources/reset.c index 7d99361f8..33698ab06 100644 --- a/sources/reset.c +++ b/sources/reset.c @@ -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");