Skip to content
This repository has been archived by the owner on Aug 13, 2019. It is now read-only.

Open db in Read only mode #588

Merged

Conversation

krasi-georgiev
Copy link
Contributor

@krasi-georgiev krasi-georgiev commented Apr 24, 2019

a better approach than #541 (Thanks to Bartek's review.)

fixes #516

TODO:

  • open an issue for the TODO comments refactoring.

Signed-off-by: Krasi Georgiev kgeorgie@redhat.com

Krasi Georgiev added 2 commits April 24, 2019 17:22
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
@bwplotka
Copy link
Contributor

Also we need to think about our use case. In current design we have only snaphot reader. There is no one syncing blocks if some writer changes it

@bwplotka
Copy link
Contributor

Sorry for another PR: #589

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
db.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

So there was some version that I liked: no reference to db and purerly read all by DBReadOnly on Block and Querier, However you changed it back to the version with db. Why? IMO it's wrong as you read only struct has access to wrtie methods in db so it's easy to "write" something by accident.

I closed my PR as I like your idea more to sync in Querier and Block on demand, but with that thing is not longer View it's rather DBReadOnly name more as you had before. Can we revert the naming?

Also there are lots of side fixes, can those go in separate PR for clarity?

db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Krasi Georgiev added 3 commits May 6, 2019 12:12
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
…tive

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
…tive

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
@krasi-georgiev krasi-georgiev mentioned this pull request May 30, 2019
@krasi-georgiev krasi-georgiev changed the title Read only alternative Open db in Read only mode May 30, 2019
@krasi-georgiev
Copy link
Contributor Author

@bwplotka , @brancz

I did a bit more work on this and I think it is ready for a final review.

Copy link
Contributor

@codesome codesome left a comment

Choose a reason for hiding this comment

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

Are we planning to guarantee "read only" here? Because it is still possible to call Delete() and CleanTombstones() from a Block. If we want to assure read-only at all levels, we may need a BlockReadOnly.

cmd/tsdb/main.go Outdated Show resolved Hide resolved
cmd/tsdb/main.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
@krasi-georgiev
Copy link
Contributor Author

ping @bwplotka

Copy link
Contributor

@codesome codesome left a comment

Choose a reason for hiding this comment

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

Few comments, didn't have time to look at the tests and wal.go.

cmd/tsdb/main.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Show resolved Hide resolved
head.go Show resolved Hide resolved
testutil/directory.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
@krasi-georgiev
Copy link
Contributor Author

ping @codesome @bwplotka for a review.

Copy link
Contributor

@codesome codesome left a comment

Choose a reason for hiding this comment

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

LGTM. Just 1 comment.

testutil/directory.go Outdated Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
codesome and others added 2 commits July 16, 2019 15:09
Signed-off-by: Ganesh Vernekar <cs15btech11018@iith.ac.in>
@gouthamve
Copy link
Collaborator

Can you hold off one more day? I plan to review this tomorrow but if I don't do anything tomorrow, feel free to merge, I don't forsee any issues :)

@krasi-georgiev
Copy link
Contributor Author

@gouthamve thanks! waiting for the review.

@bwplotka
Copy link
Contributor

Reviewing now (:

Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Nice one! Looking good, I think it's super close to be done, but I think we can still improve it bit:

  • for defers when doing exitWithError
  • I am quite confused with thread safety for DBReadOnly. I think we can improve that part. Let me know if I understood the comment corectly.

Plus some other nits.

Let me know what's your thoughts @krasi-georgiev

block.go Show resolved Hide resolved
cmd/tsdb/main.go Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
head.go Show resolved Hide resolved
head.go Outdated Show resolved Hide resolved
head.go Show resolved Hide resolved
head.go Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
…b into read-only-alternative

Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Thanks!

Further thoughts.

CHANGELOG.md Outdated Show resolved Hide resolved
cmd/tsdb/main.go Show resolved Hide resolved
cmd/tsdb/main.go Outdated
}
printBlocks(db.Blocks(), listCmdHumanReadable)
defer func() {
err = db.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

This will mask actual error, so we need some kind of multierror here or something like Thanos have: https://github.com/improbable-eng/thanos/blob/master/pkg/runutil/runutil.go#L113

I would really either import this runutil package from Thanos OR move to TSDB (someday Prometheus), so Thanos can import TSDB I guess (:

Also we are extending this package with: thanos-io/thanos#1302

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

db.go Show resolved Hide resolved
db.mtx.Unlock()
}

dbWritable := &DB{
Copy link
Contributor

Choose a reason for hiding this comment

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

// TODO(Github-issue): Refactor DB to have writer implementation using pure reader implementation not the opposite.

Potentially with github issue for that.

db.go Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
db.go Outdated Show resolved Hide resolved
head.go Show resolved Hide resolved
head.go Show resolved Hide resolved
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Signed-off-by: Krasi Georgiev <8903888+krasi-georgiev@users.noreply.github.com>
Copy link
Contributor

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks (:

Cannot see this Meta comment we were talking about - for special head implementation of BlockReader behaviour. Otherwise LGTM (:

head.go Show resolved Hide resolved
@bwplotka
Copy link
Contributor

@krasi-georgiev krasi-georgiev merged commit 6f9bbc7 into prometheus-junkyard:master Jul 23, 2019
@krasi-georgiev krasi-georgiev deleted the read-only-alternative branch July 23, 2019 08:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TSDB CLI tool doesn't work on live Prometheus
5 participants