diff options
author | Han Zhou <hzhou@ovn.org> | 2019-11-13 09:33:59 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2019-11-21 10:51:10 -0800 |
commit | 9bfb280a1705b4daa51daf9c3a66f3a67a9f0f7d (patch) | |
tree | 652079a6031d73810be8aeb934bebea72176e885 /ovsdb | |
parent | ea5c1ba0e3b899b8b6684f23a44bbfd4331815ee (diff) | |
download | openvswitch-9bfb280a1705b4daa51daf9c3a66f3a67a9f0f7d.tar.gz |
ovsdb raft: Fix election timer parsing in snapshot RPC.
Commit a76ba825 took care of saving and restoring election timer in
file header snapshot, but it didn't handle the parsing of election
timer in install_snapshot_request/reply RPC, which results in problems,
e.g. when election timer change log is compacted in snapshot and then a
new node join the cluster, the new node will use the default timer
instead of the new value. This patch fixed it by parsing election
timer in snapshot RPC.
At the same time the patch updates the test case to cover the DB compact and
join senario. The test reveals another 2 problems related to clustered DB
compact, as commented in the test case's XXX, which need to be addressed
separately.
Signed-off-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'ovsdb')
-rw-r--r-- | ovsdb/raft-rpc.c | 5 | ||||
-rw-r--r-- | ovsdb/raft.c | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/ovsdb/raft-rpc.c b/ovsdb/raft-rpc.c index 56c07d487..18c83fe9c 100644 --- a/ovsdb/raft-rpc.c +++ b/ovsdb/raft-rpc.c @@ -511,6 +511,7 @@ raft_install_snapshot_request_to_jsonrpc( json_object_put(args, "last_servers", json_clone(rq->last_servers)); json_object_put_format(args, "last_eid", UUID_FMT, UUID_ARGS(&rq->last_eid)); + raft_put_uint64(args, "election_timer", rq->election_timer); json_object_put(args, "data", json_clone(rq->data)); } @@ -527,6 +528,9 @@ raft_install_snapshot_request_from_jsonrpc( rq->last_index = raft_parse_required_uint64(p, "last_index"); rq->last_term = raft_parse_required_uint64(p, "last_term"); rq->last_eid = raft_parse_required_uuid(p, "last_eid"); + /* election_timer is optional in file header, but is always populated in + * install_snapshot_request. */ + rq->election_timer = raft_parse_required_uint64(p, "election_timer"); rq->data = json_nullable_clone( ovsdb_parser_member(p, "data", OP_OBJECT | OP_ARRAY)); @@ -541,6 +545,7 @@ raft_format_install_snapshot_request( ds_put_format(s, " last_term=%"PRIu64, rq->last_term); ds_put_format(s, " last_eid="UUID_FMT, UUID_ARGS(&rq->last_eid)); ds_put_cstr(s, " last_servers="); + ds_put_format(s, " election_timer=%"PRIu64, rq->election_timer); struct hmap servers; struct ovsdb_error *error = diff --git a/ovsdb/raft.c b/ovsdb/raft.c index a45c7f8ba..f354d50a5 100644 --- a/ovsdb/raft.c +++ b/ovsdb/raft.c @@ -3257,7 +3257,7 @@ raft_send_install_snapshot_request(struct raft *raft, .last_servers = raft->snap.servers, .last_eid = raft->snap.eid, .data = raft->snap.data, - .election_timer = raft->election_timer, + .election_timer = raft->election_timer, /* use latest value */ } }; raft_send(raft, &rpc); |