-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENG-3011 #93 Fix trying to read ahead of the log while preparing peer…
… request Summary: Here is the commit message of the Kudu fix by Todd Lipcon (apache/kudu@a8a7773). This fixes an error which often ends up in the logs when the WAL is under a lot of load: ``` E0823 01:22:37.049101 24094 consensus_queue.cc:415] T 6ffafa79dd91459fb6a55da4b52f477d P 1a6f2219a4cc41f5803b03f8c4498f56 [LEADER]: Error trying to read ahead of the log while preparing peer request: Incomplete: Op with index 294511 is ahead of the local log (next sequential op: 294511). Destination peer: Peer: b039d94e5c3f486e907e7567d148cf21, Is new: false, Last received: 3.294511, Next index: 294512, Last known committed idx: 294508, Last exchange result: SUCCESS, Needs tablet copy: false ``` As described in the JIRA (https://goo.gl/J1DyhM), the issue was the following: - in LogCache::AppendOperations, we do the following order: 1. under lock: add new operations to the cache map 2. outside lock: Log::AsyncAppendReplicates (which may block when under load) 3. under lock: increase next_sequential_op_index_ - in LogCache::ReadOps(...), we do: 1. Look for the operation in the cache. 2. If it's a hit, iterate forward in the cache until we stop "hitting" So the following interleaving caused the error to be loggged: Thread 1 --------- - call LogCache::AppendOperations() with batch 10..20 - inserts 10..20 into the cache - blocks on AsyncAppendReplicates Thread 2 --------- - preparing a request for a follower, calls ReadOps(10) --- results in ops 10..20 being copied into the outgoing request - sends the request Later, while Thread 1 is still blocked: - response received from the peer for 10..20. 'last_replicated' = 20, so next_index = 21 - we call ReadOps(21) --- next_sequential_op_id_ has still not advanced from 10 --- this triggers the error message indicated above The fix, as hinted in the JIRA (https://goo.gl/J1DyhM), is to update 'next_sequential_op_index_' before appending to the log, rather than after. This doesn't have any looser guarantees in terms of durability, since the WAL append itself is completely asynchronous -- appending to the WAL just enqueues the entries onto an in-memory queue and then asynchronously wakes up the background WAL appender thread. The new unit test crashed very rapidly without the fix with a CHECK failure showing the same Status::Incomplete() message as expected. With the fix it runs reliably. (end of imported commit message). ------------------------------------------------------------------------------------------------- In addition to the above, the following enhancements are included in this revision: - Use YB_DEFINE_ENUM for the RequestTriggerMode enum. - Miscellaneous comment cleanup. - A couple of UBSAN suppressions for the AWS C++ client. - Various improvements to repeat_unit_test.sh: ability to stop on failure, time reporting. - yb_build.sh fixes for running tests on a different host. - Try to set unlimited core limit in `run-with-timeout.cc`. - `remote_build.py` should not force the build type to be "debug" by default -- the default should be decided by `yb_build.sh`. Test Plan: Jenkins Reviewers: amitanand, venkatesh, hector, bogdan, bharat Reviewed By: hector Subscribers: bharat, ybase Differential Revision: https://phabricator.dev.yugabyte.com/D4320
- Loading branch information
Showing
19 changed files
with
451 additions
and
383 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.