]> git.proxmox.com Git - ovs.git/commit
ovsdb raft: Fix duplicated transaction execution when leader failover.
authorHan Zhou <hzhou8@ebay.com>
Fri, 12 Apr 2019 23:26:28 +0000 (16:26 -0700)
committerBen Pfaff <blp@ovn.org>
Mon, 15 Apr 2019 20:16:02 +0000 (13:16 -0700)
commit5a9b53a51ec9e81ffc2a0bcd53245291ec186af5
tree39bdf77f9a19850aef4ede668887e91aefa76372
parent7ef3608942f545a880c566e8df75ca3d177a32ad
ovsdb raft: Fix duplicated transaction execution when leader failover.

When a transaction is submitted from a client connected to a follower,
if leader crashes after receiving the execute_command_request from the
follower and sending out append request to the majority of followers,
but before sending execute_command_reply to the follower. The
transaction would finally got commited by the new leader. However,
with current implementation the transaction would be commited twice.

For the root cause, there are two cases:

Case 1, the connected follower becomes the new leader. In this case,
the pending command of the follower will be cancelled during its role
changing to leader, so the trigger for the transaction will be retried.

Case 2, another follower becomes the new leader. In this case, since
there is no execute_command_reply from the original leader (which has
crashed), the command will finally timed out, causing the trigger for
the transaction retried.

In both cases, the transaction will be retried by the server node's
trigger retrying logic. This patch fixes the problem by below changes:

1) A pending command can be completed not only by
execute_command_reply, but also when the eid is committed, if the
execute_command_reply never came.

2) Instead of cancelling all pending commands during role change, let
the commands continue waiting to be completed when the eid is
committed. The timer is increased to be twice the election base time,
so that it has the chance to be completed when leader crashes.

This patch fixes the two raft failure test cases previously disabled.
See the test case for details of how to reproduce the problem.

Signed-off-by: Han Zhou <hzhou8@ebay.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
ovsdb/raft.c
tests/ovsdb-cluster.at