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 WAL directory tailer #1

Merged
merged 1 commit into from
May 30, 2018
Merged

Add WAL directory tailer #1

merged 1 commit into from
May 30, 2018

Conversation

fabxc
Copy link
Contributor

@fabxc fabxc commented May 29, 2018

@jkohen this should do the job but let me know whether we need some additional insight like current (segment, offset) or similar.

Copy link
Contributor

@jkohen jkohen left a comment

Choose a reason for hiding this comment

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

Neat, this is looking good. Good question wrt. API, I think for now simple is good.

tail/tail.go Outdated
type tailer struct {
ctx context.Context
dir string
next int
Copy link
Contributor

Choose a reason for hiding this comment

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

can you call this nextNoun, for documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why "noun"?

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant as a placeholder. I'm not sure what noun you're tracking there.

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 – changed it to nextSegment.

// Tail the prommetheus/tsdb write ahead log in the given directory. Checkpoints
// are read before reading any WAL segments.
// Tailing may fail if we are racing with the DB itself in deleting obsolete checkpoints
// and segments. The caller should implement relevant logic to retry in those cases.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the relevant logic to call this method again? Is that the only failure mode, and if not, should we add a retriable error?

Copy link
Contributor Author

@fabxc fabxc May 29, 2018

Choose a reason for hiding this comment

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

We could add a special error. Many things could fail of course – anything along file opens/reads/etc. It's hard (and probably sometimes impossible) to tell which ones a permanent failures.
I'd just go with the caller retrying with a backoff strategy. Since none of this writes data, we shouldn't be messing anything up.

@@ -0,0 +1,112 @@
package tail
Copy link
Contributor

Choose a reason for hiding this comment

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

Add the Google license.

tail/tail.go Outdated
if err == tsdb.ErrNotFound {
// Next segment doesn't exist yet. We'll probably just have to
// wait for more data to be written.
time.Sleep(time.Second)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you intend to pass backoff instead of time.Second?

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! :)

Signed-off-by: Fabian Reinartz <freinartz@google.com>
Copy link
Contributor

@jkohen jkohen left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants