-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds functionality to clear out bad shard list #25398
base: master-1.x
Are you sure you want to change the base?
Changes from all commits
cb3abb4
eea6127
76616ff
cda3457
0b9c2a3
c4abeac
f1bf633
884a857
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -262,6 +262,70 @@ func TestStore_BadShard(t *testing.T) { | |
} | ||
} | ||
|
||
func TestStore_BadShardClear(t *testing.T) { | ||
const errStr = "a shard open error" | ||
indexes := tsdb.RegisteredIndexes() | ||
for _, idx := range indexes { | ||
func() { | ||
s := MustOpenStore(t, idx) | ||
defer require.NoErrorf(t, s.Close(), "closing store with index type: %s", idx) | ||
|
||
sh := tsdb.NewTempShard(idx) | ||
shId := sh.ID() | ||
err := s.OpenShard(sh.Shard, false) | ||
require.NoError(t, err, "opening temp shard") | ||
defer require.NoError(t, sh.Close(), "closing temporary shard") | ||
|
||
expErr := errors.New(errStr) | ||
s.SetShardOpenErrorForTest(sh.ID(), expErr) | ||
err2 := s.OpenShard(sh.Shard, false) | ||
require.Error(t, err2, "no error opening bad shard") | ||
require.ErrorIs(t, err2, tsdb.ErrPreviousShardFail{}) | ||
require.EqualError(t, err2, fmt.Errorf("not attempting to open shard %d; opening shard previously failed with: %w", shId, expErr).Error()) | ||
|
||
require.Equal(t, 1, len(s.Store.GetBadShardList())) | ||
|
||
badShards := s.ClearBadShardList() | ||
require.Len(t, badShards, 1) | ||
|
||
// Check that bad shard list has been cleared | ||
require.Empty(t, s.Store.GetBadShardList()) | ||
|
||
s.SetShardOpenErrorForTest(sh.ID(), expErr) | ||
err2 = s.OpenShard(sh.Shard, false) | ||
require.Error(t, err2, "no error opening bad shard") | ||
require.ErrorIs(t, err2, tsdb.ErrPreviousShardFail{}) | ||
require.EqualError(t, err2, fmt.Errorf("not attempting to open shard %d; opening shard previously failed with: %w", shId, expErr).Error()) | ||
|
||
// Check that bad shard list now has a bad shard in it | ||
require.Len(t, s.Store.GetBadShardList(), 1) | ||
}() | ||
} | ||
} | ||
|
||
func TestStore_BadShardClearNoBadShards(t *testing.T) { | ||
indexes := tsdb.RegisteredIndexes() | ||
for _, idx := range indexes { | ||
func() { | ||
s := MustOpenStore(t, idx) | ||
defer require.NoErrorf(t, s.Close(), "closing store with index type: %s", idx) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice error checking! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't
|
||
|
||
sh := tsdb.NewTempShard(idx) | ||
err := s.OpenShard(sh.Shard, false) | ||
require.NoError(t, err, "opening temp shard") | ||
defer require.NoError(t, sh.Close(), "closing temporary shard") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, when is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a |
||
|
||
require.Empty(t, s.Store.GetBadShardList()) | ||
|
||
badShards := s.ClearBadShardList() | ||
require.Empty(t, badShards) | ||
|
||
// Check that bad shard list has been cleared | ||
require.Empty(t, s.Store.GetBadShardList()) | ||
}() | ||
} | ||
} | ||
|
||
func TestStore_CreateMixedShards(t *testing.T) { | ||
t.Parallel() | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this close the store immediately, because arguments to deferred functions are evaluated at the
defer
line? See hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm interesting - this similar construct is used through out the tests (outside of the ones I worked on)
I'll go through this and see what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a look at the Go playground link I shared for a demonstration.