replybuf[len] = replyRequested ? 1 : 0; /* replyRequested */
len += 1;
- elog(LOG, "sending feedback (force %d, reply requested %d) to %X/%X",
+ elog(DEBUG1, "sending feedback (force %d, reply requested %d) to %X/%X",
force, replyRequested,
(uint32) (blockpos >> 32), (uint32) blockpos);
if (PQputCopyData(conn, replybuf, len) <= 0 || PQflush(conn))
{
- elog(ERROR, "could not send feedback packet: %s",
- PQerrorMessage(conn));
+ ereport(ERROR,
+ (errmsg("could not send feedback packet: %s",
+ PQerrorMessage(conn))));
return false;
}
errdetail("Both system identifiers are %s.", remote_sysid)));
}
else
- elog(LOG, "local sysid %s, remote: %s",
+ elog(DEBUG1, "local sysid %s, remote: %s",
local_sysid, remote_sysid);
/*
/* now commit local identifier */
CommitTransactionCommand();
CurrentResourceOwner = bdr_saved_resowner;
- elog(LOG, "created replication identifier %u", *replication_identifier);
+ elog(DEBUG1, "created replication identifier %u", *replication_identifier);
if (snapshot)
*snapshot = pstrdup(PQgetvalue(res, 0, 2));
if (OidIsValid(*out_replication_identifier))
{
- elog(LOG, "found valid replication identifier %u",
+ elog(DEBUG1, "found valid replication identifier %u",
*out_replication_identifier);
if (out_snapshot)
*out_snapshot = NULL;
*/
/* create local replication identifier and a remote slot */
- elog(LOG, "Creating new slot %s", NameStr(*out_slot_name));
+ elog(DEBUG1, "Creating new slot %s", NameStr(*out_slot_name));
bdr_create_slot(streamConn, out_slot_name, remote_ident,
out_replication_identifier, out_snapshot);
}
CurrentResourceOwner = ResourceOwnerCreate(NULL, "bdr apply top-level resource owner");
bdr_saved_resowner = CurrentResourceOwner;
- elog(LOG, "%s initialized on %s",
+ elog(DEBUG1, "%s initialized on %s",
MyBgworkerEntry->bgw_name, NameStr(bdr_apply_config->dbname));
streamConn = bdr_establish_connection_and_slot(
*/
start_from = RemoteCommitFromCachedReplicationIdentifier();
- elog(LOG, "starting up replication at %u from %X/%X",
+ elog(INFO, "starting up replication at %u from %X/%X",
replication_identifier,
(uint32) (start_from >> 32), (uint32) start_from);
if (r == -1)
{
- elog(LOG, "data stream ended");
+ elog(DEBUG1, "data stream ended");
return;
}
else if (r == -2)
if (strcmp(cur_option->keyword, "dbname") == 0)
{
if (cur_option->val == NULL)
- elog(ERROR, "bdr %s: no dbname set", name);
+ ereport(ERROR, (errmsg("bdr %s: no dbname set", name)));
strncpy(NameStr(opts->dbname), cur_option->val,
NAMEDATALEN);
{
elog(DEBUG2, "bdr %s: has init_replica=t", name);
if (database_initcons[off] != NULL)
- elog(ERROR, "Connections %s and %s on database %s both have bdr_init_replica enabled, cannot continue",
- name, database_initcons[off], used_databases[off]);
+ ereport(ERROR,
+ (errmsg("Connections %s and %s on database %s both have bdr_init_replica enabled, cannot continue",
+ name, database_initcons[off], used_databases[off])));
else
database_initcons[off] = name; /* no need to pstrdup, see _PG_init */
}
if (!RegisterDynamicBackgroundWorker(&apply_worker,
&bgw_handle))
{
- elog(ERROR, "bdr: Failed to register background worker"
- " %s, see previous log messages",
- NameStr(cfg->name));
+ ereport(ERROR,
+ (errmsg("bdr: Failed to register background worker"
+ " %s, see previous log messages",
+ NameStr(cfg->name))));
}
apply_workers = lcons(bgw_handle, apply_workers);
}
/* Do we need to init the local DB from a remote node? */
bdr_init_replica(&bdr_perdb_worker->dbname);
- elog(LOG, "Starting bdr apply workers for db %s", NameStr(bdr_perdb_worker->dbname));
+ elog(DEBUG1, "Starting bdr apply workers for db %s", NameStr(bdr_perdb_worker->dbname));
/* Launch the apply workers */
apply_workers = bdr_launch_apply_workers(NameStr(bdr_perdb_worker->dbname));
pfree(h);
}
- elog(LOG, "BDR starting sequencer on db \"%s\"",
+ elog(DEBUG1, "BDR starting sequencer on db \"%s\"",
NameStr(bdr_perdb_worker->dbname));
/* initialize sequencer */
int connection_config_idx;
if (!process_shared_preload_libraries_in_progress)
- elog(ERROR, "bdr can only be loaded via shared_preload_libraries");
+ ereport(ERROR,
+ (errmsg("bdr can only be loaded via shared_preload_libraries")));
if (!commit_ts_enabled)
ereport(ERROR,
if (bdr_max_workers == -1)
{
bdr_max_workers = list_length(connames) * 2;
- elog(LOG, "bdr: bdr_max_workers unset, configuring for %d workers",
+ elog(DEBUG1, "bdr: bdr_max_workers unset, configuring for %d workers",
bdr_max_workers);
}
con->seq_slot = off;
- elog(LOG, "starting bdr database worker for db %s", NameStr(con->dbname));
+ elog(DEBUG1, "starting bdr database worker for db %s", NameStr(con->dbname));
snprintf(perdb_worker.bgw_name, BGW_MAXLEN,
"bdr: %s", NameStr(con->dbname));
perdb_worker.bgw_main_arg = PointerGetDatum(con);
else
elog(ERROR, "cache lookup failed for schema bdr");
- elog(LOG, "bdr.bdr_queued_commands OID set to %u", QueuedDDLCommandsRelid);
- elog(LOG, "bdr.bdr_queued_drops OID set to %u", QueuedDropsRelid);
+ elog(DEBUG1, "bdr.bdr_queued_commands OID set to %u", QueuedDDLCommandsRelid);
+ elog(DEBUG1, "bdr.bdr_queued_drops OID set to %u", QueuedDropsRelid);
bdr_conflict_handlers_init();
(uint32) (origlsn >> 32), (uint32) origlsn,
timestamptz_to_str(committime));
- elog(LOG, "%s", statbuf);
+ elog(DEBUG1, "%s", statbuf);
pgstat_report_activity(STATE_RUNNING, statbuf);
origin_lsn = pq_getmsgint64(s);
}
- elog(LOG, "COMMIT origin(lsn, end, timestamp): %X/%X, %X/%X, %s",
+ elog(DEBUG1, "COMMIT origin(lsn, end, timestamp): %X/%X, %X/%X, %s",
(uint32) (commit_lsn >> 32), (uint32) commit_lsn,
(uint32) (end_lsn >> 32), (uint32) end_lsn,
timestamptz_to_str(committime));
#ifdef VERBOSE_INSERT
initStringInfo(&o);
tuple_to_stringinfo(&o, RelationGetDescr(rel), slot->tts_tuple);
- elog(LOG, "INSERT:%s", o.data);
+ elog(DEBUG1, "INSERT:%s", o.data);
resetStringInfo(&o);
#endif
tuple_to_stringinfo(&o, RelationGetDescr(rel), oldslot->tts_tuple);
appendStringInfo(&o, " to");
tuple_to_stringinfo(&o, RelationGetDescr(rel), remote_tuple);
- elog(LOG, "UPDATE:%s", o.data);
+ elog(DEBUG1, "UPDATE:%s", o.data);
resetStringInfo(&o);
#endif
#ifdef VERBOSE_UPDATE
initStringInfo(&o);
tuple_to_stringinfo(&o, RelationGetDescr(rel), user_tuple);
- elog(LOG, "USER tuple:%s", o.data);
+ elog(DEBUG1, "USER tuple:%s", o.data);
resetStringInfo(&o);
#endif
oldslot->tts_tuple);
bdr_count_update_conflict();
- ereport(ERROR,
+ ereport(LOG,
(errcode(ERRCODE_INTEGRITY_CONSTRAINT_VIOLATION),
errmsg("CONFLICT: could not find existing tuple for pkey %s",
o.data)));
#ifdef VERBOSE_DELETE
initStringInfo(&o);
tuple_to_stringinfo(&o, RelationGetDescr(idxrel), slot->tts_tuple);
- elog(LOG, "DELETE old-key:%s", o.data);
+ elog(DEBUG1, "DELETE old-key:%s", o.data);
resetStringInfo(&o);
#endif
estate);
if (recheckIndexes != NIL)
- elog(ERROR, "bdr doesn't don't support index rechecks");
+ ereport(ERROR,
+ (errmsg("bdr doesn't support index rechecks")));
}
/* FIXME: recheck the indexes */
size_t current_offset;
if (!superuser())
- elog(ERROR, "blarg");
+ ereport(ERROR,
+ (errmsg("Access to pg_stat_get_bdr() denied as non-superuser")));
if (rsinfo == NULL || !IsA(rsinfo, ReturnSetInfo))
ereport(ERROR,
StringInfoData query;
char *sqlstate;
- elog(LOG, "bdr %s: Dropping slot and local ident from connection %s",
+ elog(DEBUG1, "bdr %s: Dropping slot and local ident from connection %s",
NameStr(cfg->dbname), NameStr(cfg->name));
snprintf(conninfo_repl, sizeof(conninfo_repl),
}
envp[0] = path.data;
- elog(LOG, "Creating replica with: %s --snapshot %s --source \"%s\" --target \"%s\" --tmp-directory \"%s\"",
+ elog(DEBUG1, "Creating replica with: %s --snapshot %s --source \"%s\" --target \"%s\" --tmp-directory \"%s\"",
bdr_init_replica_script_path, snapshot, cfg->dsn,
cfg->replica_local_dsn, tmpdir);
char *init_snapshot = NULL;
PGconn *init_repl_conn = NULL;
- elog(LOG, "bdr %s: initializing from remote db", NameStr(*dbname));
+ elog(DEBUG1, "bdr %s: initializing from remote db", NameStr(*dbname));
/*
* We're starting from scratch or have cleaned up a previous failed
* ask to be included in dumps. In particular, bdr.bdr_nodes will get
* copied over.
*/
- elog(LOG, "bdr %s: creating and restoring dump for %s",
+ elog(DEBUG1, "bdr %s: creating and restoring dump for %s",
NameStr(*dbname), NameStr(init_replica_config->name));
bdr_exec_init_replica(init_replica_config, init_snapshot);
PQfinish(init_repl_conn);
Assert(status == 'c');
/* Launch the catchup worker and wait for it to finish */
- elog(LOG, "bdr %s: launching catchup mode apply worker", NameStr(*dbname));
+ elog(DEBUG1, "bdr %s: launching catchup mode apply worker", NameStr(*dbname));
min_remote_lsn = bdr_get_remote_lsn(nonrepl_init_conn);
bdr_catchup_to_lsn(
init_replica_worker->worker_data.apply_worker.connection_config_idx,
min_remote_lsn);
status = bdr_set_remote_status(nonrepl_init_conn, dbname, 'r', status);
- elog(LOG, "bdr %s: catchup worker finished, ready for normal replication",
+ elog(INFO, "bdr %s: catchup worker finished, ready for normal replication",
NameStr(*dbname));
PQfinish(nonrepl_init_conn);
}
if (worker_shmem_idx == bdr_max_workers)
{
LWLockRelease(BdrWorkerCtl->lock);
- elog(ERROR, "No free bdr worker slots, bdr_max_workers=%d too low",
- bdr_max_workers);
+ ereport(ERROR,
+ (errmsg("No free bdr worker slots, bdr_max_workers=%d too low",
+ bdr_max_workers)));
}
BdrWorkerCtl->slots[worker_shmem_idx].worker_type = BDR_WORKER_APPLY;
catchup_worker = &BdrWorkerCtl->slots[worker_shmem_idx].worker_data.apply_worker;
data->client_sizeof_datum != sizeof(Datum))
{
data->allow_binary_protocol = false;
- elog(LOG, "disabling binary protocol because of sizeof differences");
+ elog(DEBUG1, "disabling binary protocol because of sizeof differences");
}
else if (data->client_bigendian != bdr_get_bigendian())
{
data->allow_binary_protocol = false;
- elog(LOG, "disabling binary protocol because of endianess difference");
+ elog(DEBUG1, "disabling binary protocol because of endianess difference");
}
/*
if (data->bdr_conflict_handlers_reloid == InvalidOid)
elog(ERROR, "cache lookup for relation bdr.bdr_conflict_handlers failed");
else
- elog(LOG, "bdr.bdr_conflict_handlers OID set to %u",
+ elog(DEBUG1, "bdr.bdr_conflict_handlers OID set to %u",
data->bdr_conflict_handlers_reloid);
}
else
}
else
- {
elog(ERROR, "unsupported tuple type");
- }
}
else if (use_sendrecv)
{
if (ret != SPI_OK_INSERT)
elog(ERROR, "expected SPI state %u, got %u", SPI_OK_INSERT, ret);
my_processed = SPI_processed;
- elog(LOG, "started %d votes", my_processed);
+ elog(DEBUG1, "started %d votes", my_processed);
if (my_processed > 0)
goto again;
if (ret != SPI_OK_INSERT_RETURNING)
elog(ERROR, "expected SPI state %u, got %u", SPI_OK_INSERT_RETURNING, ret);
- elog(LOG, "started %d elections", SPI_processed);
+ elog(DEBUG1, "started %d elections", SPI_processed);
PopActiveSnapshot();
SPI_finish();
if (ret != SPI_OK_SELECT)
elog(ERROR, "expected SPI state %u, got %u", SPI_OK_SELECT, ret);
- elog(LOG, "tallied %d elections", SPI_processed);
+ elog(DEBUG1, "tallied %d elections", SPI_processed);
PopActiveSnapshot();
SPI_finish();
int i;
bool acquired_new = false;
- elog(LOG, "checking sequence %u: %s.%s",
+ elog(DEBUG1, "checking sequence %u: %s.%s",
seqoid, seqschema, seqname);
/* lock page, fill heaptup */
if (curval->next_value == curval->end_value)
{
if (curval->end_value > 0)
- elog(LOG, "used up old chunk");
+ elog(DEBUG1, "used up old chunk");
- elog(LOG, "need new batch %i", i);
+ elog(DEBUG1, "need new batch %i", i);
if (bdr_sequencer_fill_chunk(seqoid, seqschema, seqname, curval))
acquired_new = true;
else