summaryrefslogtreecommitdiff
path: root/ovsdb/raft-private.c
diff options
context:
space:
mode:
authorHan Zhou <hzhou8@ebay.com>2019-08-22 14:08:22 -0700
committerBen Pfaff <blp@ovn.org>2019-08-23 14:42:57 -0700
commita76ba8254ddd35b81190c7380fc66b9765e9b9fd (patch)
tree1cdc5b5862855f11801e845ed1ef5034f20e2fe5 /ovsdb/raft-private.c
parentac3ba8c64830e20fc65ece025f2812edb75c58f2 (diff)
downloadopenvswitch-a76ba8254ddd35b81190c7380fc66b9765e9b9fd.tar.gz
raft: Save and read new election timer in header snapshot.
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>
Diffstat (limited to 'ovsdb/raft-private.c')
-rw-r--r--ovsdb/raft-private.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/ovsdb/raft-private.c b/ovsdb/raft-private.c
index 98c68a958..26d39a087 100644
--- a/ovsdb/raft-private.c
+++ b/ovsdb/raft-private.c
@@ -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;