mirror of
https://github.com/openvswitch/ovs
synced 2025-10-29 15:28:56 +00:00
When a strong reference to a non-root table is ephemeral, the database log can contain inconsistencies. In particular, if the column in question is the only reference to a row, then the row will be created in one logged transaction but the reference to it will not be logged (because it is ephemeral). Thus, any later occurrence of the row later in the log (to modify it, to delete it, or just to reference it) will yield a transaction error and reading the database will abort at that point. This commit fixes the problem by forcing any column with a strong reference to a non-root table to be persistent. The change to ovsdb_schema_from_json() looks bigger than it really is: it just swaps the order of two operations on the schema and updates their comments. Similarly for the update to ovs.db.DbSchema.__init__(). Bug #5144. Reported-by: Sujatha Sumanth <ssumanth@nicira.com> Bug #5149. Reported-by: Ram Jothikumar <rjothikumar@nicira.com>
104 lines
3.5 KiB
Plaintext
104 lines
3.5 KiB
Plaintext
AT_BANNER([OVSDB -- schemas])
|
|
|
|
OVSDB_CHECK_POSITIVE_CPY([schema with valid refTables],
|
|
[[parse-schema \
|
|
'{"name": "mydb",
|
|
"version": "4.2.1",
|
|
"tables": {
|
|
"a": {
|
|
"columns": {
|
|
"map": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "b"},
|
|
"value": {
|
|
"type": "uuid",
|
|
"refTable": "a"}}}}},
|
|
"b": {
|
|
"columns": {
|
|
"aRef": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "a"}}}}}}}']],
|
|
[[{"name":"mydb","tables":{"a":{"columns":{"map":{"type":{"key":{"refTable":"b","type":"uuid"},"value":{"refTable":"a","type":"uuid"}}}}},"b":{"columns":{"aRef":{"type":{"key":{"refTable":"a","type":"uuid"}}}}}},"version":"4.2.1"}]])
|
|
|
|
dnl Ephemeral strong references to root set tables are OK.
|
|
dnl Ephemeral strong references to non-root set tables are forced to be
|
|
dnl persistent.
|
|
OVSDB_CHECK_POSITIVE_CPY([schema with ephemeral strong references],
|
|
[[parse-schema \
|
|
'{"name": "mydb",
|
|
"version": "4.2.1",
|
|
"tables": {
|
|
"a": {
|
|
"columns": {
|
|
"x": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "b"}},
|
|
"ephemeral": true},
|
|
"y": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "a"}},
|
|
"ephemeral": true}}},
|
|
"b": {
|
|
"columns": {
|
|
"aRef": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "a"}}}},
|
|
"isRoot": true}}}']],
|
|
[[{"name":"mydb","tables":{"a":{"columns":{"x":{"ephemeral":true,"type":{"key":{"refTable":"b","type":"uuid"}}},"y":{"type":{"key":{"refTable":"a","type":"uuid"}}}}},"b":{"columns":{"aRef":{"type":{"key":{"refTable":"a","type":"uuid"}}}},"isRoot":true}},"version":"4.2.1"}]])
|
|
|
|
dnl Schemas without version numbers are accepted for backward
|
|
dnl compatibility, but this is a deprecated feature.
|
|
OVSDB_CHECK_POSITIVE_CPY([schema without version number],
|
|
[[parse-schema \
|
|
'{"name": "mydb",
|
|
"tables": {
|
|
"x": {
|
|
"columns": {
|
|
"y": {
|
|
"type": "integer"}}}}}']],
|
|
[{"name":"mydb","tables":{"x":{"columns":{"y":{"type":"integer"}}}}}])
|
|
|
|
OVSDB_CHECK_NEGATIVE_CPY([schema with invalid refTables],
|
|
[[parse-schema \
|
|
'{"name": "mydb",
|
|
"tables": {
|
|
"a": {
|
|
"columns": {
|
|
"map": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "c"},
|
|
"value": {
|
|
"type": "uuid",
|
|
"refTable": "a"}}}}},
|
|
"b": {
|
|
"columns": {
|
|
"aRef": {
|
|
"type": {
|
|
"key": {
|
|
"type": "uuid",
|
|
"refTable": "a"}}}}}}}']],
|
|
[[syntax error: column map key refers to undefined table c]])
|
|
|
|
OVSDB_CHECK_NEGATIVE_CPY([schema with invalid version number],
|
|
[[parse-schema \
|
|
'{"name": "mydb",
|
|
"tables": {
|
|
"x": {
|
|
"columns": {
|
|
"y": {
|
|
"type": "integer"}}}},
|
|
"version": "xxx"}']],
|
|
[[schema version "xxx" not in format x.y.z]])
|