-
Notifications
You must be signed in to change notification settings - Fork 453
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
Handle commit log files with corrupt info headers during cleanup and bootstrap #1066
Changes from all commits
8cf4917
949025c
9674341
f0ad534
16827fe
a53a56d
cecfa02
4eea9bd
60ca533
a274193
d870758
3883221
f138227
ad5d08b
c14f51c
6515237
e60e7e2
acf3b34
cbf359e
422c423
e829864
be684ff
0fd6c9d
f57e71b
9883df1
d4aacfe
c3de970
c976906
ce9beca
02ce8e4
07284d5
979ecf7
d5a159b
18e405e
7a94eaf
d5e10e6
48b671a
c300a20
a380187
d490cde
6e167e2
9a6849c
fa4b0c3
926308c
656df6e
da67bf7
b8020fe
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 |
---|---|---|
|
@@ -38,23 +38,24 @@ import ( | |
) | ||
|
||
func TestFiles(t *testing.T) { | ||
// TODO(r): Find some time/people to help investigate this flakey test. | ||
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. lol is this no longer flaky? 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. yeah I fixed it 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. 👍 |
||
t.Skip() | ||
|
||
dir, err := ioutil.TempDir("", "commitlogs") | ||
require.NoError(t, err) | ||
defer os.RemoveAll(dir) | ||
|
||
createTestCommitLogFiles(t, dir, 10*time.Minute, 5) | ||
|
||
opts := NewOptions() | ||
var ( | ||
minNumBlocks = 5 | ||
opts = NewOptions() | ||
) | ||
opts = opts.SetFilesystemOptions( | ||
opts.FilesystemOptions(). | ||
SetFilePathPrefix(dir), | ||
) | ||
files, err := Files(opts) | ||
files, corruptFiles, err := Files(opts) | ||
require.NoError(t, err) | ||
require.Equal(t, 5, len(files)) | ||
require.True(t, len(corruptFiles) == 0) | ||
require.True(t, len(files) >= minNumBlocks) | ||
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. ah is this the fix? 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. yep |
||
|
||
// Make sure its sorted | ||
var lastFileStart time.Time | ||
|
@@ -71,12 +72,12 @@ func TestFiles(t *testing.T) { | |
} | ||
} | ||
|
||
// createTestCommitLogFiles creates the specified number of commit log files | ||
// on disk with the appropriate block size. Commit log files will be valid | ||
// and contain readable metadata. | ||
// createTestCommitLogFiles creates at least the specified number of commit log files | ||
// on disk with the appropriate block size. Commit log files will be valid and contain | ||
// readable metadata. | ||
func createTestCommitLogFiles( | ||
t *testing.T, filePathPrefix string, blockSize time.Duration, numBlocks int) { | ||
require.True(t, numBlocks >= 2) | ||
t *testing.T, filePathPrefix string, blockSize time.Duration, minNumBlocks int) { | ||
require.True(t, minNumBlocks >= 2) | ||
|
||
var ( | ||
nowLock = sync.RWMutex{} | ||
|
@@ -109,13 +110,12 @@ func createTestCommitLogFiles( | |
} | ||
// Commit log writer is asynchronous and performs batching so getting the exact number | ||
// of files that we want is tricky. The implementation below loops infinitely, writing | ||
// a single datapoint and increasing the time after each iteration until numBlocks -1 | ||
// files are on disk. After that, it terminates, and the final batch flush from calling | ||
// commitlog.Close() will generate the last file. | ||
// a single datapoint and increasing the time after each iteration until minNumBlocks | ||
// files are on disk. | ||
for { | ||
files, err := fs.SortedCommitLogFiles(commitLogsDir) | ||
require.NoError(t, err) | ||
if len(files) == numBlocks-1 { | ||
if len(files) >= minNumBlocks { | ||
break | ||
} | ||
err = commitLog.Write(context.NewContext(), series, ts.Datapoint{}, xtime.Second, nil) | ||
|
@@ -126,5 +126,5 @@ func createTestCommitLogFiles( | |
require.NoError(t, commitLog.Close()) | ||
files, err := fs.SortedCommitLogFiles(commitLogsDir) | ||
require.NoError(t, err) | ||
require.Equal(t, numBlocks, len(files)) | ||
require.True(t, len(files) >= minNumBlocks) | ||
} |
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.
why sort at all? and if you're going to sort - you can sort errors first (or last) and then guarantee order too.
or better yet change the return type for this function:
([]File, []ErrorWithPath, error)
and then won't need the FileOrError type.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.
Sorting is important because you want to try and read the commit log files in order in the bootstrapper
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.
Your interface change suggestion is good though, just made it