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

BZ1 Pt. II #3544

Merged
merged 5 commits into from
Aug 5, 2015
Merged

BZ1 Pt. II #3544

merged 5 commits into from
Aug 5, 2015

Conversation

benbjohnson
Copy link
Contributor

Overview

This pull request is another attempt at the bz1 engine. The original can be found at #3461.

This approach changes the engine to support an underlying WAL which is being moved out to a separate package. The WAL work is being done by @pauldix. The bz1 engine now supports a passthrough interface to a PointsWriter (which will be the WAL) and implements a function that the WAL periodically calls back to:

func (e *Engine) WriteIndex(pointsByKey map[string][][]byte) error

Implementation

The WriteIndex() function supports two separate write paths:

  • "append" - Points for a key are all after the last point in the database. This is the fast path and it will simply append additional blocks onto the end.
  • "insert" - Points for a key are intermixed with existing points. This is the slow path because it has to read out all the compressed blocks for the time range, combine them with the new points, and then rewrite all the blocks to disk.

There are two separate paths because most of the time users will be writing new data to the end of a series. The slow path mainly exists so that data can be backfilled.

TODO

  • Implement append (fast path)
  • Implement insert (slow path)
  • Implement testing/quick black box testing

if err := e.writeBlocks(bkt, a); err != nil {
return fmt.Errorf("append blocks: %s", err)
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the fast path. It grabs the last block in the bucket, reads the first 8 bytes (which is the ending timestamp), and if the minimum time for the inserted points is greater than that then it can simply append new blocks.

Otherwise it's a big PITA to read out and reinsert blocks as you can see below.

}

// Delete block in database.
c.Delete()
Copy link
Member

Choose a reason for hiding this comment

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

just want to confirm that I'm reading this right. Because this happens in a transaction, the Delete and then the creation of a new block will be atomic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes

@pauldix
Copy link
Member

pauldix commented Aug 5, 2015

Big one, but looks great. Just a few questions I had above.

benbjohnson added a commit that referenced this pull request Aug 5, 2015
@benbjohnson benbjohnson merged commit 4436036 into influxdata:master Aug 5, 2015
@benbjohnson benbjohnson deleted the bz1 branch August 5, 2015 22:57
@toddboom
Copy link
Contributor

toddboom commented Aug 6, 2015

👏 👏 👏

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

3 participants