ovsdb-server: Improve logging for referential integrity violations.
authorBen Pfaff <blp@nicira.com>
Fri, 11 Jun 2010 20:56:36 +0000 (13:56 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 22 Jun 2010 18:48:51 +0000 (11:48 -0700)
This may help with bug #2727 "ovs-vsctl transaction error while changing
VM power state", if it is reproducible.

ovsdb/transaction.c
tests/ovsdb-execution.at
tests/ovsdb-idl.at

index 218fbce3edd34710422192f14e7966d18c3e99c7..bfa2fcbad65c20dc1cc59640be6596596fd4a6f1 100644 (file)
@@ -152,7 +152,8 @@ find_txn_row(const struct ovsdb_table *table, const struct uuid *uuid)
 }
 
 static struct ovsdb_error * WARN_UNUSED_RESULT
-ovsdb_txn_adjust_atom_refs(struct ovsdb_txn *txn,
+ovsdb_txn_adjust_atom_refs(struct ovsdb_txn *txn, const struct ovsdb_row *r,
+                           const struct ovsdb_column *c,
                            const struct ovsdb_base_type *base,
                            const union ovsdb_atom *atoms, unsigned int n,
                            int delta)
@@ -174,8 +175,12 @@ ovsdb_txn_adjust_atom_refs(struct ovsdb_txn *txn,
                 txn_row = ovsdb_txn_row_modify(txn, row)->txn_row;
             } else {
                 return ovsdb_error("referential integrity violation",
-                                   "reference to nonexistent row "
-                                   UUID_FMT, UUID_ARGS(uuid));
+                                   "Table %s column %s row "UUID_FMT" "
+                                   "references nonexistent row "UUID_FMT" in "
+                                   "table %s.",
+                                   r->table->schema->name, c->name,
+                                   UUID_ARGS(ovsdb_row_get_uuid(r)),
+                                   UUID_ARGS(uuid), table->schema->name);
             }
         }
         txn_row->n_refs += delta;
@@ -191,10 +196,10 @@ ovsdb_txn_adjust_row_refs(struct ovsdb_txn *txn, const struct ovsdb_row *r,
     const struct ovsdb_datum *field = &r->fields[column->index];
     struct ovsdb_error *error;
 
-    error = ovsdb_txn_adjust_atom_refs(txn, &column->type.key,
+    error = ovsdb_txn_adjust_atom_refs(txn, r, column, &column->type.key,
                                        field->keys, field->n, delta);
     if (!error) {
-        error = ovsdb_txn_adjust_atom_refs(txn, &column->type.value,
+        error = ovsdb_txn_adjust_atom_refs(txn, r, column, &column->type.value,
                                            field->values, field->n, delta);
     }
     return error;
index a6f14355f6f5b19095b246486c5321528ffffb7e..394fcba721c26042744878acd99befbfa99fa6e2 100644 (file)
@@ -580,7 +580,7 @@ OVSDB_CHECK_EXECUTION([referential integrity -- mutual references],
        "table": "b",
        "where": [["b", "==", 1]]}]]]],
   [[[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]
-[{"uuid":["uuid","<2>"]},{"details":"reference to nonexistent row <3>","error":"referential integrity violation"}]
+[{"uuid":["uuid","<2>"]},{"details":"Table a column a2b row <2> references nonexistent row <3> in table b.","error":"referential integrity violation"}]
 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
 [{"count":1},{"details":"cannot delete b row <1> because of 1 remaining reference(s)","error":"referential integrity violation"}]
 [{"count":1},{"details":"cannot delete a row <0> because of 1 remaining reference(s)","error":"referential integrity violation"}]
index 9b90b032c5f837ca65e835c091df17f0b1de0a69..9223de3bcbc7149cd8028e10c272bdfd4f7cd3ac 100644 (file)
@@ -265,11 +265,11 @@ OVSDB_CHECK_IDL([self-linking idl, inconsistent ops],
        "where": []}]' \
 ]],
   [[000: empty
-001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"reference to nonexistent row <1>","error":"referential integrity violation"}]}
+001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"details":"Table link1 column k row <0> references nonexistent row <1> in table link1.","error":"referential integrity violation"}]}
 002: {"error":null,"result":[{"uuid":["uuid","<2>"]},{"uuid":["uuid","<3>"]}]}
 003: i=1 k=1 ka=[] l2= uuid=<2>
 003: i=2 k=1 ka=[] l2= uuid=<3>
-004: {"error":null,"result":[{"count":2},{"details":"reference to nonexistent row <4>","error":"referential integrity violation"}]}
+004: {"error":null,"result":[{"count":2},{"details":"Table link1 column k row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
 005: {"error":null,"result":[{"count":1},{"details":"cannot delete link1 row <2> because of 1 remaining reference(s)","error":"referential integrity violation"}]}
 006: {"error":null,"result":[{"count":1}]}
 007: i=1 k=1 ka=[] l2= uuid=<2>
@@ -305,8 +305,8 @@ OVSDB_CHECK_IDL([self-linking idl, sets],
     '["idltest",
       {"op": "update",
        "table": "link1",
-       "where": [],
-       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"], ["uuid", "1ac2b12e-b767-4805-a55d-43976e40c465"]]]}}]' \
+       "where": [["i", "==", 2]],
+       "row": {"ka": ["set", [["uuid", "#0#"], ["uuid", "88702e78-845b-4a6e-ad08-cf68922ae84a"], ["uuid", "#2#"]]]}}]' \
     '+["idltest",
       {"op": "delete",
        "table": "link1",
@@ -322,7 +322,7 @@ OVSDB_CHECK_IDL([self-linking idl, sets],
 004: i=1 k=0 ka=[0 1 2 3] l2= uuid=<1>
 004: i=2 k=0 ka=[0 1 2 3] l2= uuid=<2>
 004: i=3 k=0 ka=[0 1 2 3] l2= uuid=<3>
-005: {"error":null,"result":[{"count":4},{"details":"reference to nonexistent row <4>","error":"referential integrity violation"}]}
+005: {"error":null,"result":[{"count":1},{"details":"Table link1 column ka row <2> references nonexistent row <4> in table link1.","error":"referential integrity violation"}]}
 006: {"error":null,"result":[{"count":4}]}
 007: empty
 008: done