2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-28 12:58:00 +00:00

ovsdb: Fix OVSDB disconnect replication bug

Currently disconnecting from the replicator server means closing the
jsonrpc connection and destroying the monitored table names and
blacklisted table names.

This patch makes a distinction between disconnecting from the
remote server, applicable when the replication incurs in an error,
and destroying the remote server info, applicable when ovsdb-server
exits gracefully.

Signed-off-by: Mario Cabrera <mario.cabrera@hpe.com>
This commit is contained in:
Mario Cabrera 2016-06-28 15:14:53 -06:00 committed by Andy Zhou
parent 38f453801b
commit c9c5c9e201
3 changed files with 23 additions and 12 deletions

View File

@ -371,7 +371,7 @@ main(int argc, char *argv[])
sset_destroy(&remotes); sset_destroy(&remotes);
sset_destroy(&db_filenames); sset_destroy(&db_filenames);
unixctl_server_destroy(unixctl); unixctl_server_destroy(unixctl);
disconnect_remote_server(); destroy_remote_server();
if (run_process && process_exited(run_process)) { if (run_process && process_exited(run_process)) {
int status = process_status(run_process); int status = process_status(run_process);

View File

@ -140,6 +140,14 @@ get_tables_blacklist(void)
void void
disconnect_remote_server(void) disconnect_remote_server(void)
{
jsonrpc_close(rpc);
sset_clear(&monitored_tables);
sset_clear(&tables_blacklist);
}
void
destroy_remote_server(void)
{ {
jsonrpc_close(rpc); jsonrpc_close(rpc);
sset_destroy(&monitored_tables); sset_destroy(&monitored_tables);
@ -447,20 +455,19 @@ process_notification(struct json *table_updates, struct ovsdb *database)
} }
} }
if (!error){
/* Commit transaction. */
error = ovsdb_txn_commit(txn, false);
if (error) { if (error) {
ovsdb_error_assert(error);
sset_clear(&monitored_tables);
}
} else {
ovsdb_txn_abort(txn); ovsdb_txn_abort(txn);
ovsdb_error_assert(error); goto error;
sset_clear(&monitored_tables);
} }
ovsdb_error_destroy(error); /* Commit transaction. */
error = ovsdb_txn_commit(txn, false);
error:
if (error) {
ovsdb_error_assert(error);
disconnect_remote_server();
}
} }
static struct ovsdb_error * static struct ovsdb_error *
@ -500,6 +507,9 @@ process_table_update(struct json *table_update, const char *table_name,
error = execute_update(txn, node->name, table, new); error = execute_update(txn, node->name, table, new);
} }
} }
if (error) {
break;
}
} }
return error; return error;
} }

View File

@ -37,6 +37,7 @@ const char *get_remote_ovsdb_server(void);
void set_tables_blacklist(const char *blacklist); void set_tables_blacklist(const char *blacklist);
struct sset get_tables_blacklist(void); struct sset get_tables_blacklist(void);
void disconnect_remote_server(void); void disconnect_remote_server(void);
void destroy_remote_server(void);
const struct db *find_db(const struct shash *all_dbs, const char *db_name); const struct db *find_db(const struct shash *all_dbs, const char *db_name);
void replication_usage(void); void replication_usage(void);