-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add support for TSI shard streaming and shard size #8491
Conversation
6aa05c8
to
6d1f805
Compare
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.
Minor comments. Otherwise lgtm.
CHANGELOG.md
Outdated
#### `[continuous_queries]` Section | ||
|
||
* `query-stats-enabled` was added with a default of `false`. When set to `true`, continuous query execution statistics are written to the default monitor store. | ||
======= | ||
the configured maximum size, a `413 Request Entity Too Large` HTTP response is returned. | ||
>>>>>>> Add support for TSI shard streaming and shard size |
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.
Merge conflict?
tsdb/engine/tsm1/engine.go
Outdated
@@ -666,6 +662,8 @@ func (e *Engine) overlay(r io.Reader, basePath string, asNew bool) error { | |||
return nil, err | |||
} | |||
|
|||
// The filestore will only handle tsm files. Other file types will be | |||
// ignored. |
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 must you leave orphaned words in comment lines!?!? 😡
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 rage brings me so much joy ❤️ .
@@ -2253,9 +2253,9 @@ func TestFileStore_Stats(t *testing.T) { | |||
"mem": []tsm1.Value{tsm1.NewValue(0, 1.0)}, | |||
}) | |||
|
|||
replacement := files[2] + "-foo" + ".tmp" // Assumes new files have a .tmp extension | |||
replacement := fmt.Sprintf("%s.%s.%s", files[2], tsm1.TmpTSMFileExtension, tsm1.TSMFileExtension) // Assumes new files have a .tmp extension |
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.
Should Tmp extension be at the end?
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.
@benbjohnson I changed the implementation to check for either .tsm.tmp
or .tsm
. The previous test was creating a filename ending in -foo.tmp
, which didn't match the new filters, so I updated the test to come up with a new filename that matched one of the filters.
b253ed8
to
93e35f1
Compare
tsdb/engine/tsm1/engine.go
Outdated
e.mu.RUnlock() | ||
return "", err | ||
} | ||
e.mu.RUnlock() |
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.
I think the engine should still be locked while the index is snapshotted. If it's unlocked, it's possible the index and tsm files could be inconsistent if deletes and writes were running.
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.
Looks like this was a pre-existing bug in that case. I'll add the lock protection.
9a73263
to
04901fe
Compare
CHANGELOG.md
Outdated
@@ -107,7 +108,11 @@ The following new configuration options are available. | |||
* `max-body-size` was added with a default of 25,000,000, but can be disabled by setting it to 0. | |||
Specifies the maximum size (in bytes) of a client request body. When a client sends data that exceeds | |||
the configured maximum size, a `413 Request Entity Too Large` HTTP response is returned. | |||
<<<<<<< HEAD |
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.
Bad merge...
tsdb/engine/tsm1/engine.go
Outdated
@@ -707,15 +705,27 @@ func (e *Engine) overlay(r io.Reader, basePath string, asNew bool) error { | |||
return err | |||
} | |||
|
|||
if idx, ok := e.index.(*tsi1.Index); ok { |
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.
I think this may create a race now since it's accessing the index w/o a RLock.
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.
There may be other accesses to e.index
that need to be protected now too.
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.
e.index
is still accessed outside of a RLock
.
340045f
to
4d14ff0
Compare
@jwilder is this good to go now? @benbjohnson can you check 4d14ff058181bda032e9fbed702f4255381be099. I didn't include these fields originally and as I was rebasing it occurred to me that we probably need to set them. |
for _, fi := range tmpfiles { | ||
if fi.IsDir() && strings.HasSuffix(fi.Name(), ".tmp") { | ||
if fi.IsDir() && strings.HasSuffix(fi.Name(), ext) { |
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.
This is missing the "." now.
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.
See a couple of lines up
|
||
// Rename all the new files to make them live on restart | ||
for _, file := range newFiles { | ||
var newName = file | ||
if strings.HasSuffix(file, ".tmp") { | ||
if strings.HasSuffix(file, tsmTmpExt) { |
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.
"." is missing as well.
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.
defined on 574
func (i *Index) DiskSizeBytes() int64 { | ||
fs := i.RetainFileSet() | ||
defer fs.Release() | ||
return fs.Size() |
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.
Shard.DiskSize
is called fairly frequently. It created a lot of lock contention in tsm and I suspect it will cause a problem here as well. I ended up switching the sizes in tsm to be atomic counters to fix it.
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.
tsdb/engine/tsm1/engine.go
Outdated
@@ -707,15 +705,27 @@ func (e *Engine) overlay(r io.Reader, basePath string, asNew bool) error { | |||
return err | |||
} | |||
|
|||
if idx, ok := e.index.(*tsi1.Index); ok { |
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.
e.index
is still accessed outside of a RLock
.
3a257c1
to
c61f533
Compare
@e-dard 👍 on 4d14ff0. |
8dce31a
to
cbd91cd
Compare
This commit firstly ensures that a shard's size on disk is accurately reported when using the tsi1 index, by including the on-disk size of the tsi1 index in the calculation. Secondly, this commit add support for shard streaming/copying when using the tsi1 index. Prior to this, a tsi1 index would not be correctly restored when streaming shards.
cbd91cd
to
b10249a
Compare
// The new TSM files have a tmp extension. First rename them. | ||
newName = file[:len(file)-4] | ||
if err := os.Rename(file, newName); err != nil { | ||
return err | ||
} | ||
} else if !strings.HasSuffix(file, TSMFileExtension) { |
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.
I think this should be TmpTSMFileExtension
. New files passed in are always tmp one.
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.
That check happens in the if
above. It checks for tsmTmpExt
which is .tsm.tmp
. This else if
skips any non-tsm or non-tmp-tsm files (such as index files).
In the if
above we rename the tmp
tsm file and drop the .tmp
. Then below this else if
we process the tsm
file.
Without this else if
to skip non-tsm files I believe we could get caught up on tsi
index files.
This commit firstly ensures that a shard's size on disk is accurately
reported when using the
tsi1
index, by including the on-disk size of thetsi1
index in the calculation.Secondly, this commit add support for shard streaming/copying when using
the
tsi1
index. Prior to this, atsi1
index would not be correctlyrestored when streaming shards.
Required for all non-trivial PRs