On a server size, default values are just normal values.  The only
difference is that they are initialized from default atoms.  They are
allocated on a separate piece of memory as any other values, so there
should not be any special treatment.

Current code doesn't apply the diff to a column with default values
after reading the file transaction and that breaks the logic.

For example, if we have a column with a set and a minimum number of
elements for a type is 1, it will be initialized with one default atom.
On mutation, new values can be added and the diff will contain only
these new values, while the column will contain both the new values
and the default atom.  While reading such transaction from a file
with a diff, current code will replace the content loosing the default
atom.  The only case where we need to actually replace is if this row
doesn't exist and it's not actually a diff, i.e. if this row was just
created to be populated with a json content.

Fix that by removing the wrong check and not use values as a diff
in case the row doesn't exist in a database.

Fixes: 2ccd66f594f7 ("ovsdb: Use column diffs for ovsdb and raft log entries.")
Signed-off-by: Ilya Maximets <[email protected]>
---
 ovsdb/file.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/ovsdb/file.c b/ovsdb/file.c
index 6e7e47ca6..8bd1d4af3 100644
--- a/ovsdb/file.c
+++ b/ovsdb/file.c
@@ -118,9 +118,7 @@ ovsdb_file_update_row_from_json(struct ovsdb_row *row, bool 
converting,
         if (error) {
             return error;
         }
-        if (row_contains_diff
-            && !ovsdb_datum_is_default(&row->fields[column->index],
-                                       &column->type)) {
+        if (row_contains_diff) {
             error = ovsdb_datum_apply_diff_in_place(
                                            &row->fields[column->index],
                                            &datum, &column->type);
@@ -161,8 +159,7 @@ ovsdb_file_txn_row_from_json(struct ovsdb_txn *txn, struct 
ovsdb_table *table,
 
         new = ovsdb_row_create(table);
         *ovsdb_row_get_uuid_rw(new) = *row_uuid;
-        error = ovsdb_file_update_row_from_json(new, converting,
-                                                row_contains_diff, json);
+        error = ovsdb_file_update_row_from_json(new, converting, false, json);
         if (error) {
             ovsdb_row_destroy(new);
         } else {
-- 
2.40.1

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to