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

ReadOnly option #541

Closed

Conversation

krasi-georgiev
Copy link
Contributor

@krasi-georgiev krasi-georgiev commented Mar 5, 2019

just continuing the work from #517

fixes #516

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 added 2 commits March 6, 2019 22:16
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
nit
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
@glightfoot
Copy link

@krasi-georgiev - is there anything I can do to help with this?

@krasi-georgiev
Copy link
Contributor Author

@glightfoot no thanks , I will finish this probably tomorrow.

Krasi Georgiev added 2 commits March 27, 2019 07:34
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
@krasi-georgiev krasi-georgiev marked this pull request as ready for review March 27, 2019 05:41
Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
@krasi-georgiev
Copy link
Contributor Author

ready for review
ping @gouthamve , @codesome

Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
@krasi-georgiev
Copy link
Contributor Author

ping @gouthamve , @codesome

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.

Yo, initial review. I really like the direction of having read only TSDB - it is must have. But I think this might be totally separate struct we are looking for that exposes only READ methods like Series etc.. How hard would be to separate those vs injecting all those conditionals in the critical path. E.g I don't think we need to do reload even. Having totally separate code with some kind of composability for components that needs to be reused?

opts := *tsdb.DefaultOptions
opts.NoLockfile = true
opts.ReadOnly = true
db, err = tsdb.Open(dir, l, r, &opts)
Copy link
Contributor

Choose a reason for hiding this comment

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

return tsdb.Open(dir, l, r, &opts) is not enough?

@@ -62,9 +73,6 @@ func main() {
dumpMaxTime = dumpCmd.Flag("max-time", "maximum timestamp to dump").Default(strconv.FormatInt(math.MaxInt64, 10)).Int64()
)

safeDBOptions := *tsdb.DefaultOptions
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 I would prefer readOnlyOptions struct and pass it everywhere.

"github.com/prometheus/tsdb"
"github.com/prometheus/tsdb/chunks"
"github.com/prometheus/tsdb/labels"
"gopkg.in/alecthomas/kingpin.v2"
)

func openReadOnlyTSDB(dir string, l log.Logger, r prometheus.Registerer) (db *tsdb.DB, err error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure why those logger and registerer opts if you never fill them (: I think it proves that just readOnlyOpts struct would be enough instead of this function

@@ -79,6 +80,10 @@ type Options struct {
// Overlapping blocks are allowed if AllowOverlappingBlocks is true.
// This in-turn enables vertical compaction and vertical query merge.
AllowOverlappingBlocks bool

// ReadOnly disables all mutating actions.
Copy link
Contributor

Choose a reason for hiding this comment

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

"Disables", means it will return error when acessing Appender methods etc?


// ReadOnly disables all mutating actions.
// Useful for opening the same db more than once.
ReadOnly bool
Copy link
Contributor

Choose a reason for hiding this comment

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

Have we considered totally different constructor instead returning limited TSDB interface ?

@@ -588,8 +598,10 @@ func (db *DB) reload() (err error) {
}
}

if err := db.deleteBlocks(deletable); err != nil {
return err
if !db.opts.ReadOnly {
Copy link
Contributor

Choose a reason for hiding this comment

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

All those ifs in this file. Do we really need to invoke reload and exactly the same Open functions in readOnly TSDB mode?

What readOnly mode should give? I think only tiny shim for Querying, right? Can we just add separate layer that does just that? It would massively reduce extra complexity in critical code here. What do you think? (:

@krasi-georgiev krasi-georgiev mentioned this pull request Apr 24, 2019
1 task
@krasi-georgiev
Copy link
Contributor Author

superseded by #588

@krasi-georgiev krasi-georgiev deleted the readonly-db branch May 31, 2019 09:38
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
3 participants