We shouldn't terminate with an error if no event record could be created

Event records are advisory and non-critical; there may be paths
where we're not able to connect to a valid master and hence unable
to write a record. (If an 'event_notification_command' is defined,
this should serve as a backup notification of the event).
This commit is contained in:
Ian Barwick
2015-03-19 23:09:29 +09:00
parent 9a3196b671
commit ce66a7c2d2

View File

@@ -775,21 +775,14 @@ do_master_register(void)
exit(ERR_DB_QUERY); exit(ERR_DB_QUERY);
} }
/* Log the event */ /* Log the event */
record_created = create_event_record(conn, create_event_record(conn,
&options, &options,
options.node, options.node,
"master_register", "master_register",
true, true,
NULL); NULL);
if(record_created == false)
{
PQfinish(conn);
exit(ERR_DB_QUERY);
}
PQfinish(conn); PQfinish(conn);
log_notice(_("master node correctly registered for cluster %s with id %d (conninfo: %s)\n"), log_notice(_("master node correctly registered for cluster %s with id %d (conninfo: %s)\n"),
@@ -889,20 +882,13 @@ do_standby_register(void)
} }
/* Log the event */ /* Log the event */
record_created = create_event_record(master_conn, create_event_record(master_conn,
&options, &options,
options.node, options.node,
"standby_register", "standby_register",
true, true,
NULL); NULL);
if(record_created == false)
{
PQfinish(master_conn);
PQfinish(conn);
exit(ERR_DB_QUERY);
}
PQfinish(master_conn); PQfinish(master_conn);
PQfinish(conn); PQfinish(conn);
@@ -1547,7 +1533,6 @@ do_standby_promote(void)
promote_check_interval = 2; promote_check_interval = 2;
bool promote_sucess = false; bool promote_sucess = false;
bool success; bool success;
bool record_created;
/* We need to connect to check configuration */ /* We need to connect to check configuration */
log_info(_("connecting to standby database\n")); log_info(_("connecting to standby database\n"));
@@ -1635,7 +1620,7 @@ do_standby_promote(void)
"Node %i could not be promoted to master", "Node %i could not be promoted to master",
options.node); options.node);
record_created = create_event_record(old_master_conn, create_event_record(old_master_conn,
&options, &options,
options.node, options.node,
"standby_promote", "standby_promote",
@@ -1656,7 +1641,7 @@ do_standby_promote(void)
log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n")); log_notice(_("STANDBY PROMOTE successful. You should REINDEX any hash indexes you have.\n"));
/* Log the event */ /* Log the event */
record_created = create_event_record(conn, create_event_record(conn,
&options, &options,
options.node, options.node,
"standby_promote", "standby_promote",
@@ -1667,11 +1652,6 @@ do_standby_promote(void)
PQfinish(old_master_conn); PQfinish(old_master_conn);
PQfinish(conn); PQfinish(conn);
if(record_created == false)
{
exit(ERR_DB_QUERY);
}
return; return;
} }
@@ -2188,19 +2168,13 @@ do_witness_create(void)
} }
/* Log the event */ /* Log the event */
record_created = create_event_record(masterconn, create_event_record(masterconn,
&options, &options,
options.node, options.node,
"witness_create", "witness_create",
true, true,
NULL); NULL);
if(record_created == false)
{
PQfinish(masterconn);
exit(ERR_DB_QUERY);
}
PQfinish(masterconn); PQfinish(masterconn);
PQfinish(witnessconn); PQfinish(witnessconn);