[ovs-dev] [PATCH ovn] ovn-northd-ddlog: Fix startup race updating nb_cfg_timestamp.

Ben Pfaff blp at ovn.org
Sat Mar 6 01:24:13 UTC 2021

The DDlog code used by ovn-northd-ddlog relies on always having a value
(exactly one of them) in the NbCfgTimestamp relation.  The C code
inserts and updates this value.  It's supposed to insert the initial
value the first time that it processes any update from the northbound

However, it actually only did this if the first update it processed was
from the northbound database--if it was from the southbound database,
it forgot to do so even when the first northbound update showed up.
The DDlog code would then go kind of berzerk creating and deleting the
NB_Global record until something actually happened to increment nb_cfg
(such as "ovn-nbctl --wait=sb sync").

This fixes the problem by only recording that a value was inserted to
NbCfgTimestamp when the first update from the northbound database is
received, same as originally intended.

Signed-off-by: Ben Pfaff <blp at ovn.org>
 northd/ovn-northd-ddlog.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/northd/ovn-northd-ddlog.c b/northd/ovn-northd-ddlog.c
index aa0ea73e401d..f373bb129a89 100644
--- a/northd/ovn-northd-ddlog.c
+++ b/northd/ovn-northd-ddlog.c
@@ -445,8 +445,10 @@ northd_parse_updates(struct northd_ctx *ctx, struct ovs_list *updates)
     if (ddlog_commit(ctx->ddlog)) {
         goto error;
-    old_nb_cfg = new_nb_cfg;
-    old_nb_cfg_timestamp = new_nb_cfg_timestamp;
+    if (ctx->has_timestamp_columns) {
+        old_nb_cfg = new_nb_cfg;
+        old_nb_cfg_timestamp = new_nb_cfg_timestamp;
+    }
     /* This update may have implications for the other side, so
      * immediately wake to check for more changes to be applied. */

More information about the dev mailing list