Skip to content

Commit

Permalink
storage: avoid deadlock during merges
Browse files Browse the repository at this point in the history
Merges could deadlock if the lease on the right-hand range was
transferred or renewed during the merge transaction and the new
leaseholder received any request before the GetSnapshotForMerge request.
See cockroachdb#27442 and the comments within for details. Avoid the deadlock by
moving the responsibility for waiting for a merge to complete from the
replica to the store.

Add a unit test that runs several get requests concurrently with several
merges to reliably test for regressions. The problem previously only
presented when stressing TestStoreRangeMergeWithData.

Fix cockroachdb#27442.

Release note: None
  • Loading branch information
benesch committed Jul 15, 2018
1 parent d8a546b commit 33c0508
Show file tree
Hide file tree
Showing 7 changed files with 505 additions and 180 deletions.
1 change: 1 addition & 0 deletions pkg/roachpb/api.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions pkg/roachpb/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -706,3 +706,13 @@ func (e *IntentMissingError) message(_ *Error) string {
}

var _ ErrorDetailInterface = &IntentMissingError{}

func (e *MergeInProgressError) Error() string {
return e.message(nil)
}

func (e *MergeInProgressError) message(_ *Error) string {
return "merge in progress"
}

var _ ErrorDetailInterface = &MergeInProgressError{}
Loading

0 comments on commit 33c0508

Please sign in to comment.