/*
- * (c) Copyright 2016 Hewlett Packard Enterprise Development LP
+ * (c) Copyright 2016, 2017 Hewlett Packard Enterprise Development LP
* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2016, 2017 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
{
free(sync_from);
sync_from = xstrdup(sync_from_);
- char *err = set_blacklist_tables(exclude_tables, false);
/* Caller should have verified that the 'exclude_tables' is
* parseable. An error here is unexpected. */
- ovs_assert(!err);
+ ovs_assert(!set_blacklist_tables(exclude_tables, false));
replication_dbs_destroy();
static void
send_schema_requests(const struct json *result)
{
- for (size_t i = 0; i < result->u.array.n; i++) {
- const struct json *name = result->u.array.elems[i];
+ for (size_t i = 0; i < result->array.n; i++) {
+ const struct json *name = result->array.elems[i];
if (name->type == JSON_STRING) {
/* Send one schema request for each remote DB. */
const char *db_name = json_string(name);
if (msg->type == JSONRPC_NOTIFY && state != RPL_S_ERR
&& !strcmp(msg->method, "update")) {
if (msg->params->type == JSON_ARRAY
- && msg->params->u.array.n == 2
- && msg->params->u.array.elems[0]->type == JSON_STRING) {
- char *db_name = msg->params->u.array.elems[0]->u.string;
+ && msg->params->array.n == 2
+ && msg->params->array.elems[0]->type == JSON_STRING) {
+ char *db_name = msg->params->array.elems[0]->string;
struct ovsdb *db = find_db(db_name);
if (db) {
struct ovsdb_error *error;
- error = process_notification(msg->params->u.array.elems[1],
+ error = process_notification(msg->params->array.elems[1],
db);
if (error) {
ovsdb_error_assert(error);
/* After receiving schemas, reset the local databases that
* will be monitored and send out monitor requests for them. */
if (hmap_is_empty(&request_ids)) {
- struct shash_node *node, *next;
-
- SHASH_FOR_EACH_SAFE (node, next, replication_dbs) {
- db = node->data;
- error = reset_database(db);
- if (error) {
- const char *db_name = db->schema->name;
- shash_find_and_delete(replication_dbs, db_name);
- ovsdb_error_assert(error);
- VLOG_WARN("Failed to reset database, "
- "%s not replicated.", db_name);
- }
- }
+ struct shash_node *node;
if (shash_is_empty(replication_dbs)) {
VLOG_WARN("Nothing to replicate.");
case RPL_S_MONITOR_REQUESTED: {
/* Reply to monitor requests. */
struct ovsdb_error *error;
- error = process_notification(msg->result, db);
+ VLOG_INFO("Monitor request received. Resetting the database");
+ /* Resetting the database here has few risks. If the
+ * process_notification() fails, the database is completely
+ * lost locally. In case that node becomes active, then
+ * there is a chance of complete data loss in the active/standy
+ * cluster. */
+ error = reset_database(db);
+ if (!error) {
+ error = process_notification(msg->result, db);
+ }
if (error) {
ovsdb_error_assert(error);
state = RPL_S_ERR;
}
}
- return ovsdb_txn_commit(txn, false);
+ return ovsdb_txn_propose_commit_block(txn, false);
}
/* Create a monitor request for 'db'. The monitor request will include
return error;
} else {
/* Commit transaction. */
- error = ovsdb_txn_commit(txn, false);
+ error = ovsdb_txn_propose_commit_block(txn, false);
}
}
break;
default:
OVS_NOT_REACHED();
- break;
}
} else {
ds_put_format(&ds, "not connected to %s", sync_from);