Skip to content
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

Merged
merged 8 commits into from
Nov 29, 2017
Merged

Conversation

e-dard
Copy link
Contributor

@e-dard e-dard commented Jun 14, 2017

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.

Required for all non-trivial PRs
  • Rebased/mergable
  • Tests pass
  • CHANGELOG.md updated

@e-dard e-dard requested review from benbjohnson and jwilder June 14, 2017 12:28
@e-dard e-dard added the review label Jun 14, 2017
@e-dard e-dard force-pushed the er-tsi-restore branch 2 times, most recently from 6aa05c8 to 6d1f805 Compare June 14, 2017 12:29
Copy link
Contributor

@benbjohnson benbjohnson left a 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflict?

@@ -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.
Copy link
Contributor

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!?!? 😡

Copy link
Contributor Author

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
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@e-dard e-dard force-pushed the er-tsi-restore branch 4 times, most recently from b253ed8 to 93e35f1 Compare June 14, 2017 16:53
e.mu.RUnlock()
return "", err
}
e.mu.RUnlock()
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@e-dard e-dard force-pushed the er-tsi-restore branch 2 times, most recently from 9a73263 to 04901fe Compare August 23, 2017 16:54
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad merge...

@@ -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 {
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

@ghost ghost assigned e-dard Oct 20, 2017
@e-dard
Copy link
Contributor Author

e-dard commented Oct 20, 2017

@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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"." is missing as well.

Copy link
Contributor Author

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()
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwilder this calls down to here on each file in the fileset. It's should be cheap.

@@ -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 {
Copy link
Contributor

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.

@e-dard
Copy link
Contributor Author

e-dard commented Oct 20, 2017

@jwilder see c61f533

@benbjohnson
Copy link
Contributor

@e-dard 👍 on 4d14ff0.

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.
// 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) {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@e-dard e-dard merged commit c2f7f0f into master Nov 29, 2017
@e-dard e-dard deleted the er-tsi-restore branch November 29, 2017 15:40
@ghost ghost removed the review label Nov 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants