struct timeval timeout;
static int connected;
int connections_count = 0; /* used if child_max_connections > 0 */
-
+ int first_ready_for_query_received; /* for master/slave mode */
pool_debug("I am %d", getpid());
* we need to connect to the backend and send the startup packet.
*/
+ first_ready_for_query_received = 0; /* for master/slave mode */
+
/* look for existing connection */
if ((backend = pool_get_cp(sp->user, sp->database, sp->major)) == NULL)
{
if ((backend = connect_backend(sp, frontend)) == NULL)
continue;
+
+ /* in master/slave mode, the first "ready for query"
+ * packet should be treated as if we were not in the
+ * mode
+ */
+ if (MASTER_SLAVE)
+ first_ready_for_query_received = 1;
}
+
else
{
/* we don't need Startup Packet info anymore */
{
POOL_STATUS status;
- status = pool_process_query(frontend, backend, 0);
+ status = pool_process_query(frontend, backend, 0, first_ready_for_query_received);
sp = MASTER_CONNECTION(backend)->sp;
POOL_STATUS status1;
/* send reset request to backend */
- status1 = pool_process_query(frontend, backend, 1);
+ status1 = pool_process_query(frontend, backend, 1, 0);
pool_close(frontend);
/* if we detect errors on resetting connection, we need to discard
extern int pool_init_cp(void);
extern POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend,
- int connection_reuse);
+ int connection_reuse,
+ int first_ready_for_query_received);
extern POOL_CONNECTION *pool_open(int fd);
extern void pool_close(POOL_CONNECTION *cp);
POOL_STATUS pool_process_query(POOL_CONNECTION *frontend,
POOL_CONNECTION_POOL *backend,
- int connection_reuse)
+ int connection_reuse,
+ int first_ready_for_query_received)
{
char kind, kind1; /* packet kind (backend) */
char fkind; /* packet kind (frontend) */
}
/* this is the synchronous point */
- if (REPLICATION)
+ if (REPLICATION || first_ready_for_query_received)
{
if (kind == 0)
{
}
}
+ first_ready_for_query_received = 0;
+
if (kind == '\0' || kind != kind1)
{
int sts;
default:
if (MAJOR(backend) == PROTO_MAJOR_V3)
{
+ if (MASTER_SLAVE)
+ {
+ master_slave_was_enabled = 1;
+ MASTER_SLAVE = 0;
+ master_slave_dml = 1;
+ }
+
status = SimpleForwardToBackend(fkind, frontend, backend);
if (pool_flush(MASTER(backend)))
status = POOL_ERROR;