]> git.proxmox.com Git - ovs.git/commitdiff
raft: Save and read new election timer in header snapshot.
authorHan Zhou <hzhou8@ebay.com>
Thu, 22 Aug 2019 21:08:22 +0000 (14:08 -0700)
committerBen Pfaff <blp@ovn.org>
Fri, 23 Aug 2019 21:42:57 +0000 (14:42 -0700)
This patch store the latest election timer in snapshot during log
compression, and when server restarts it reads the value from the log.
Without this, any previous changes to election timer will be lost
in the log, and if server restarts, it will use the default value
instead of the changed value.

Fixes: commit 8e35461 ("ovsdb raft: Support leader election time change online.")
Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Documentation/ref/ovsdb.5.rst
ovsdb/raft-private.c

index a6da65df3736bc50c3e33c27efaa9b51d7f72ae8..bb35eee6c3c7ddd3dab4a25f73768e6a88559155 100644 (file)
@@ -164,7 +164,7 @@ The clustered format has the following additional notation:
     This allows readers to be ignorant of the full semantics of schema change.
 
 The first record in a clustered database contains the following members,
-all of which are required:
+all of which are required, except ``prev_election_timer``:
 
 ``"server_id": <raw-uuid>``
     The server's own UUID, which must be unique within the cluster.
@@ -190,6 +190,10 @@ all of which are required:
     term "prev_term".  It might not include this server, if it was not the
     initial server in the cluster.
 
+``"prev_election_timer": <uint64>``
+    The election base time before the beginning of the log.  If not exist,
+    the default value 1000 ms is used as if it exists this record.
+
 ``"prev_data": <json-value>`` and ``"prev_eid": <raw-uuid>``
     A snapshot of the data in the database at index "prev_index" and term
     "prev_term", and the entry ID for that data.  The snapshot must contain a
index 98c68a9585ba70998cfeb384a6ab8b2ac6697d17..26d39a087f2639709b23d340297ed1e6842b5b36 100644 (file)
@@ -284,6 +284,7 @@ raft_entry_clone(struct raft_entry *dst, const struct raft_entry *src)
     dst->data = json_nullable_clone(src->data);
     dst->eid = src->eid;
     dst->servers = json_nullable_clone(src->servers);
+    dst->election_timer = src->election_timer;
 }
 
 void
@@ -405,6 +406,8 @@ raft_header_from_json__(struct raft_header *h, struct ovsdb_parser *p)
                 ovsdb_parser_member(p, "prev_data", OP_ANY));
             h->snap.eid = raft_parse_required_uuid(p, "prev_eid");
             h->snap.term = raft_parse_required_uint64(p, "prev_term");
+            h->snap.election_timer = raft_parse_optional_uint64(
+                p, "prev_election_timer");
         }
     }
 
@@ -457,6 +460,10 @@ raft_header_to_json(const struct raft_header *h)
         }
         json_object_put_format(json, "prev_eid",
                                UUID_FMT, UUID_ARGS(&h->snap.eid));
+        if (h->snap.election_timer) {
+            raft_put_uint64(json, "prev_election_timer",
+                            h->snap.election_timer);
+        }
     }
 
     return json;