-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43942 from nvanbenschoten/backport19.1-43937
release-19.1: storage/engine: fix re-issued KV writes with most recent seq num
- Loading branch information
Showing
3 changed files
with
82 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2020 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package enginepb | ||
|
||
import ( | ||
fmt "fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestMetadataGetPrevIntentSeq(t *testing.T) { | ||
for _, tc := range []struct { | ||
history []int32 | ||
search int32 | ||
expPrevSeq int32 | ||
expPrevFound bool | ||
}{ | ||
{[]int32{}, 0, 0, false}, | ||
{[]int32{}, 1, 0, false}, | ||
{[]int32{}, 2, 0, false}, | ||
{[]int32{}, 3, 0, false}, | ||
{[]int32{0}, 0, 0, false}, | ||
{[]int32{0}, 1, 0, true}, | ||
{[]int32{0}, 2, 0, true}, | ||
{[]int32{0}, 3, 0, true}, | ||
{[]int32{1}, 0, 0, false}, | ||
{[]int32{1}, 1, 0, false}, | ||
{[]int32{1}, 2, 1, true}, | ||
{[]int32{1}, 3, 1, true}, | ||
{[]int32{0, 1}, 0, 0, false}, | ||
{[]int32{0, 1}, 1, 0, true}, | ||
{[]int32{0, 1}, 2, 1, true}, | ||
{[]int32{0, 1}, 3, 1, true}, | ||
{[]int32{0, 2}, 0, 0, false}, | ||
{[]int32{0, 2}, 1, 0, true}, | ||
{[]int32{0, 2}, 2, 0, true}, | ||
{[]int32{0, 2}, 3, 2, true}, | ||
{[]int32{1, 2}, 0, 0, false}, | ||
{[]int32{1, 2}, 1, 0, false}, | ||
{[]int32{1, 2}, 2, 1, true}, | ||
{[]int32{1, 2}, 3, 2, true}, | ||
{[]int32{0, 1, 2}, 0, 0, false}, | ||
{[]int32{0, 1, 2}, 1, 0, true}, | ||
{[]int32{0, 1, 2}, 2, 1, true}, | ||
{[]int32{0, 1, 2}, 3, 2, true}, | ||
} { | ||
name := fmt.Sprintf("%v/%d", tc.history, tc.search) | ||
t.Run(name, func(t *testing.T) { | ||
var meta MVCCMetadata | ||
for _, seq := range tc.history { | ||
meta.IntentHistory = append(meta.IntentHistory, MVCCMetadata_SequencedIntent{ | ||
Sequence: seq, | ||
}) | ||
} | ||
|
||
prevSeq, prevFound := meta.GetPrevIntentSeq(tc.search) | ||
require.Equal(t, tc.expPrevSeq, prevSeq) | ||
require.Equal(t, tc.expPrevFound, prevFound) | ||
}) | ||
} | ||
} |
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