From: Craig Ringer Date: Thu, 15 May 2014 17:49:12 +0000 (+0800) Subject: bdr: Fix init_replica bug introduced by per-db workers in shmem X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=62535410df17dcb67baf8edece9f8193222d0ff4;p=users%2Fandresfreund%2Fpostgres.git bdr: Fix init_replica bug introduced by per-db workers in shmem Two arrays that previously always had the same offsets for any given connection no longer do after per-db workers were introduced. This exposed a previous bug in init_replica where mapping between the two arrays was not properly done. --- diff --git a/contrib/bdr/bdr_init_replica.c b/contrib/bdr/bdr_init_replica.c index 59343a42bf..d9b0cb7d89 100644 --- a/contrib/bdr/bdr_init_replica.c +++ b/contrib/bdr/bdr_init_replica.c @@ -773,7 +773,6 @@ bdr_init_replica(Name dbname) /* Cleanup done and nothing more to do */ return; - init_replica_config = bdr_connection_configs [init_replica_worker->worker_data.apply_worker.connection_config_idx]; elog(DEBUG2, "bdr %s: bdr_init_replica init from connection %s", @@ -874,6 +873,10 @@ bdr_init_replica(Name dbname) status = bdr_set_remote_status(nonrepl_init_conn, dbname, 'i', status); + /* + * A list of all connections to make slots for, as indexes into + * BdrWorkerCtl. + */ my_conn_idxs = (int*)palloc(sizeof(Size) * bdr_max_workers); /* Collect a list of connections to make slots for. */ @@ -937,7 +940,7 @@ bdr_init_replica(Name dbname) /* Always throws rather than returning failure */ Assert(conn); - if (&BdrWorkerCtl->slots[off] == init_replica_worker) + if (w == init_replica_worker) { /* * We need to keep the snapshot ID returned by CREATE SLOT so