const struct ovsdb_schema *schema, const struct json *txn_json,
const struct uuid *txnid)
{
- if (schema && (!db->db->schema || strcmp(schema->version,
- db->db->schema->version))) {
+ if (schema) {
/* We're replacing the schema (and the data). Destroy the database
* (first grabbing its storage), then replace it with the new schema.
* The transaction must also include the replacement data.
*
- * Only clustered database schema changes go through this path. */
+ * Only clustered database schema changes and snapshot installs
+ * go through this path.
+ */
ovs_assert(txn_json);
ovs_assert(ovsdb_storage_is_clustered(db->db->storage));
return error;
}
- ovsdb_jsonrpc_server_reconnect(
- config->jsonrpc, false,
- (db->db->schema
- ? xasprintf("database %s schema changed", db->db->name)
- : xasprintf("database %s connected to storage", db->db->name)));
+ if (!db->db->schema ||
+ strcmp(schema->version, db->db->schema->version)) {
+ ovsdb_jsonrpc_server_reconnect(
+ config->jsonrpc, false,
+ (db->db->schema
+ ? xasprintf("database %s schema changed", db->db->name)
+ : xasprintf("database %s connected to storage",
+ db->db->name)));
+ }
ovsdb_replace(db->db, ovsdb_create(ovsdb_schema_clone(schema), NULL));
AT_CHECK([ovsdb_client_wait unix:s$i.ovsdb $schema_name connected])
done
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "insert",
+ "table": "indexed",
+ "row": {"i": 0}}]]'], [0], [ignore], [ignore])
+
# Kill one follower (s2) and write some data to cluster, so that the follower is falling behind
printf "\ns2: stopping\n"
OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/s2], [s2.pid])
+# Delete "i":0 and readd it to get a different UUID for it.
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "delete",
+ "table": "indexed",
+ "where": [["i", "==", 0]]}]]'], [0], [ignore], [ignore])
+
AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
{"op": "insert",
- "table": "simple",
+ "table": "indexed",
+ "row": {"i": 0}}]]'], [0], [ignore], [ignore])
+
+AT_CHECK([ovsdb-client transact unix:s1.ovsdb '[["idltest",
+ {"op": "insert",
+ "table": "indexed",
"row": {"i": 1}}]]'], [0], [ignore], [ignore])
# Compact leader online to generate snapshot
# succeed.
AT_CHECK([ovsdb-client transact unix:s2.ovsdb '[["idltest",
{"op": "insert",
- "table": "simple",
- "row": {"i": 1}}]]'], [0], [ignore], [ignore])
+ "table": "indexed",
+ "row": {"i": 2}}]]'], [0], [ignore], [ignore])
+
+# The snapshot should overwrite the in-memory contents of the DB on S2
+# without generating any constraint violations. All tree records (0, 1, 2)
+# should be in the DB at this point.
+AT_CHECK([ovsdb-client --no-headings dump unix:s2.ovsdb idltest indexed | uuidfilt | sort -k 2], [0], [dnl
+<0> 0
+<1> 1
+<2> 2
+indexed table
+])
for i in `seq $n`; do
OVS_APP_EXIT_AND_WAIT_BY_TARGET([`pwd`/s$i], [s$i.pid])
# Check that ovsdb-idl figured out that table link2 and column l2 are missing.
AT_CHECK([grep ovsdb_idl stderr | sort], [0], [dnl
+test-ovsdb|ovsdb_idl|idltest database lacks indexed table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks link2 table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks simple5 table (database needs upgrade?)
test-ovsdb|ovsdb_idl|idltest database lacks singleton table (database needs upgrade?)