diff mbox series

[ovs-dev] ovsdb-idl: Don't reparse orphaned rows.

Message ID 20211126122622.6828-1-dceara@redhat.com
State Accepted
Headers show
Series [ovs-dev] ovsdb-idl: Don't reparse orphaned rows. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Dumitru Ceara Nov. 26, 2021, 12:26 p.m. UTC
Rows that refer to rows that were inserted in the current IDL run should
only be reparsed if they don't get deleted (become orphan) in the current
IDL run.

Fixes: 7b8aeadd60c8 ("ovsdb-idl: Re-parse backrefs of inserted rows only once.")
Reported-by: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
 lib/ovsdb-idl.c    |  7 ++++++-
 tests/ovsdb-idl.at | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

Comments

Ilya Maximets Nov. 30, 2021, 3:36 p.m. UTC | #1
On 11/26/21 13:26, Dumitru Ceara wrote:
> Rows that refer to rows that were inserted in the current IDL run should
> only be reparsed if they don't get deleted (become orphan) in the current
> IDL run.
> 
> Fixes: 7b8aeadd60c8 ("ovsdb-idl: Re-parse backrefs of inserted rows only once.")
> Reported-by: Ilya Maximets <i.maximets@ovn.org>
> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
> ---
>  lib/ovsdb-idl.c    |  7 ++++++-
>  tests/ovsdb-idl.at | 26 ++++++++++++++++++++++++++
>  2 files changed, 32 insertions(+), 1 deletion(-)

This one applied.  Thanks!

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index a6323d2b8b9a..b7ba25eca6b5 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -1506,10 +1506,15 @@  ovsdb_idl_reparse_refs_to_inserted(struct ovsdb_idl *db)
     struct ovsdb_idl_row *row;
 
     LIST_FOR_EACH_POP (row, reparse_node, &db->rows_to_reparse) {
+        ovs_list_init(&row->reparse_node);
+
+        /* Skip rows that have been deleted in the meantime. */
+        if (ovsdb_idl_row_is_orphan(row)) {
+            continue;
+        }
         ovsdb_idl_row_unparse(row);
         ovsdb_idl_row_clear_arcs(row, false);
         ovsdb_idl_row_parse(row);
-        ovs_list_init(&row->reparse_node);
     }
 }
 
diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index 0f229b2f9943..3adb9d638a71 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -1540,6 +1540,32 @@  OVSDB_CHECK_IDL([simple idl, initially populated, strong references, conditional
 006: done
 ]])
 
+dnl This test checks that deleting a row that refers to a row that was inserted
+dnl in the current IDL run works properly.
+OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, strong references, insert and delete],
+  [],
+  [['["idltest",
+      {"op": "insert",
+       "table": "link1",
+       "uuid-name": "uuid_l1",
+       "row": {"i": 1, "k": ["named-uuid", "uuid_l1"]}},
+      {"op": "insert",
+       "table": "link2",
+       "row": {"i": 2, "l1": ["set", [["named-uuid", "uuid_l1"]]]}}
+      ]' \
+    '+["idltest",
+      {"op": "delete",
+       "table": "link2",
+       "where": [["i", "==", 2]]}]'
+  ]],
+  [[000: empty
+001: {"error":null,"result":[{"uuid":["uuid","<0>"]},{"uuid":["uuid","<1>"]}]}
+002: {"error":null,"result":[{"count":1}]}
+003: table link1: inserted row: i=1 k=1 ka=[] l2= uuid=<0>
+003: table link1: updated columns: i k
+004: done
+]])
+
 OVSDB_CHECK_IDL_TRACK([track, simple idl, initially empty, various ops],
   [],
   [['["idltest",