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,20 +775,13 @@ 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);
@@ -889,19 +882,12 @@ 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,12 +1620,12 @@ 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",
false, false,
details.data); details.data);
/* XXX exit with error? */ /* XXX exit with error? */
log_err(_(retval == 1 ? log_err(_(retval == 1 ?
"STANDBY PROMOTE failed, this is still a standby node.\n" : "STANDBY PROMOTE failed, this is still a standby node.\n" :
@@ -1656,22 +1641,17 @@ 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",
true, true,
details.data); details.data);
} }
PQfinish(old_master_conn); PQfinish(old_master_conn);
PQfinish(conn); PQfinish(conn);
if(record_created == false)
{
exit(ERR_DB_QUERY);
}
return; return;
} }
@@ -2188,18 +2168,12 @@ 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);