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

feat: integrated sqlite db for metadata #21543

Merged
merged 7 commits into from
May 25, 2021
Merged

Conversation

williamhbaker
Copy link
Contributor

Closes #21260
Closes #21261

This sets up the basic functionality of a sqlite metadata store in the application. There is a wrapper around the *sql.DB which provides a few utility methods including flushing the database tables of data for end-to-end testing and applying database migrations upon startup of influxd.

The migration system uses go-bindata which is pretty clunky compared to the native embedding that is part of go1.16, and I hope to refactor the migration code when we upgrade.

It is also worth pointing out that this includes changes to the flags used to start influxd, including:

  • The --store flag used to work with string values of bolt or memory - it will now work with disk or memory, and also bolt for backwards compatibility. Using either disk or bolt utilizes on-disk storage for metadata, whereas memory uses temporary in-memory databases for testing purposes.
  • There is a new --sqlite-path flag for specifying the path to the sqlite database! This is comparable to the --bolt-path and --engine-path flags. If a --bolt-path is specified but not a --sqlite-path, the --sqlite-path will be set to store the sqlite database with the default name in the same directory as specified by the --bolt-path.

@williamhbaker williamhbaker force-pushed the wb-sqlite-metadb-21260 branch from 47a64fb to dfe5fa1 Compare May 24, 2021 20:21
Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

Some early thoughts, looking great overall

cmd/influxd/launcher/launcher.go Outdated Show resolved Hide resolved
cmd/influxd/launcher/launcher.go Show resolved Hide resolved
cmd/influxd/upgrade/upgrade_test.go Outdated Show resolved Hide resolved
sqlite/migrations/staticcheck.conf Show resolved Hide resolved
sqlite/sqlite.go Show resolved Hide resolved
sqlite/sqlite.go Outdated Show resolved Hide resolved
sqlite/sqlite.go Outdated Show resolved Hide resolved
@williamhbaker williamhbaker marked this pull request as ready for review May 24, 2021 20:34
go.mod Outdated
@@ -58,6 +58,7 @@ require (
github.com/kevinburke/go-bindata v3.11.0+incompatible
github.com/lib/pq v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.12
github.com/mattn/go-sqlite3 v1.11.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Curious, why v1.11.0 instead of the lastest v1.14.7?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No particular reason - v1.11.0 was actually in the go.sum (has been for a while it looks like...?) so I guess that's why it ended up being v1.11.0 in go.mod. That's pretty old and there's no specific reason for us to not use the latest version so I updated to v1.14.7.

Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

Needs some CHANGELOGing as well! For something this big I'd probably add a dedicated section at the top about adding sqlite in general (see previous releases where we had blurbs about adding ARM, or about breaking APIs). Then there could be 2 lines in the "new features" section for:

  • Adding the --sqlite-path config option
  • Adding the disk option to --store

@williamhbaker
Copy link
Contributor Author

Needs some CHANGELOGing as well! For something this big I'd probably add a dedicated section at the top about adding sqlite in general (see previous releases where we had blurbs about adding ARM, or about breaking APIs). Then there could be 2 lines in the "new features" section for:

* Adding the `--sqlite-path` config option

* Adding the `disk` option to `--store`

Oh yeah definitely...I updated the change log, let me know if it makes sense.

Copy link
Contributor

@danxmoran danxmoran left a comment

Choose a reason for hiding this comment

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

LGTM assuming the CI failure is flakiness

@williamhbaker williamhbaker merged commit 19b0470 into master May 25, 2021
@williamhbaker williamhbaker deleted the wb-sqlite-metadb-21260 branch May 25, 2021 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants