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

Batched write support #1644

Merged
merged 17 commits into from
Feb 21, 2015
Merged

Batched write support #1644

merged 17 commits into from
Feb 21, 2015

Conversation

otoolep
Copy link
Contributor

@otoolep otoolep commented Feb 19, 2015

No description provided.

@otoolep
Copy link
Contributor Author

otoolep commented Feb 19, 2015

Most definitely work-in-progress. It compiles, but that's about it, and is not complete. The corresponding "apply" commands have yet to be coded.

@otoolep
Copy link
Contributor Author

otoolep commented Feb 19, 2015

I have also not performed any testing, short of the new unit tests.

if err != nil {
return err
}
db.addSeriesToIndex(cm.Name, series)
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 @pauldix -- this is in the proposed "apply batched series and field creation" code. This has a race such that if an addition of a series fails to be committed to the Metastore, any changes to in-memory indexes, due to the calls to db.addSeriesToIndex(), are not rolled back. Pre-existing code also suffered from this issue with relation to fields.

This means, in a failure scenario, we could end up with a different data in memory versus in the Metatsore. We can avoid this by cloning the in-RAM indexes for the purposes of the loop, and then swapping the modified clone and in-RAM authoritative copy at the very end of the function, assuming no errors.

Make sense? Is there another approach? Do we care?

Copy link
Contributor

Choose a reason for hiding this comment

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

mustUpdate() should cause the server to crash hard so that when it comes back up it'll rebuild its in-memory index.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes, indeed it will. Nice.

Copy link
Member

Choose a reason for hiding this comment

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

another thing to do is to put the update of the in memory structures after the metastore update, but before it releases the database schema lock

@otoolep otoolep force-pushed the batched_series_create branch 2 times, most recently from 85628c2 to b445457 Compare February 20, 2015 06:22
@otoolep
Copy link
Contributor Author

otoolep commented Feb 20, 2015

This patch can be summarized by two key changes:

  • the creation of the createMeasurementsIfNotExistsCommand, which allows multiple Measurements, Series, and Fields, to be created in 1 Raft message. Other Series and Field related Raft messages have been removed.
  • the write path now loops through all points in a batch, demultiplexes the data into separate buffers (byte slices) for each shard on the cluster. These buffers are then sent one after the other to the Brokers (room for optimization here), for routing to the shards. On receipt of the buffers, the data nodes then write each of these buffers to Bolt, with a transaction per buffer. Previously each point resulted in a transaction.

Best case is a batch comes in that results in a single buffer i.e. all points in the batch are destined for the same shard. This would mean a single batch is routed around the cluster in a single message, and that single batch is written to Bolt in a single transaction.

@benbjohnson
Copy link
Contributor

@otoolep the changes lgtm. we'll need to handle batching coming from different clients as well in the future but we can do that in a separate PR. 🚢

for _, p := range points {
// Local function makes lock management foolproof.
measurement, series, err := func() (*Measurement, *Series, error) {
s.mu.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

this lock should be outside the points loop

@pauldix
Copy link
Member

pauldix commented Feb 20, 2015

A few comments, but otherwise looks good.

otoolep and others added 5 commits February 20, 2015 11:28
Using maps was resulting in unpredicatable ordering of columns and tags.
Its presence is making Bolt-level batching quite awkward, and since it's
not used, just remove it.
In addition, memomize the Field codecs.
otoolep added a commit that referenced this pull request Feb 21, 2015
@otoolep otoolep merged commit 1522842 into master Feb 21, 2015
@otoolep otoolep deleted the batched_series_create branch February 21, 2015 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants