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

PostgreSQL quota manager and storage backend #3644

Merged
merged 65 commits into from
Nov 7, 2024

Conversation

robstradling
Copy link
Contributor

@robstradling robstradling commented Oct 8, 2024

This PR is based on Trillian's existing MySQL quota manager and storage backend. The first several commits were auto-generated by this script, which forked the existing MySQL code into different directories (whilst preserving the git history) and then did a bunch of search'n'replacing to switch from the database/sql interface to the jackc/pgx interface.

Improving performance is my main reason for using the pgx interface directly. In particular, the pgx interface has allowed me to use PostgreSQL's COPY interface for fast bulk-upserts.

My motivations for putting together this PR are that (1) I and my colleagues at Sectigo have a fair amount of experience with PostgreSQL, but almost no experience with MySQL/MariaDB; and (2) we suffered a CT log failure earlier this year due to MariaDB corruption after disk space exhaustion, and we are confident that PostgreSQL would not have broken under the same circumstances.

Checklist

@roger2hk
Copy link
Contributor

roger2hk commented Oct 8, 2024

/gcbrun

Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

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

Looking great @robstradling. I've reviewed up to the meaty bits. Looking good so far. A few nitty comments, and then a request for some brief docs to help me understand the flows in the storage layers. Once that's done (and I've had my lunch) I can take a look over the remaining files.

.github/workflows/test_pgdb.yaml Show resolved Hide resolved
@@ -49,10 +49,12 @@ import (
_ "github.com/google/trillian/storage/cloudspanner"
_ "github.com/google/trillian/storage/crdb"
_ "github.com/google/trillian/storage/mysql"
_ "github.com/google/trillian/storage/postgresql"
Copy link
Contributor

Choose a reason for hiding this comment

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

You're following the existing pattern which is the right thing to do. However, I think this pattern is kinda suspect in that it leads to pretty massive binaries. This small change here increases the size of the log server binary by another 10%.

❯ ls -l trillian_log_server
.rwxr-xr-x 61M mhutchinson 30 Oct 11:21 trillian_log_server
❯ go build ./cmd/trillian_log_server
❯ ls -l trillian_log_server
.rwxr-xr-x 67M mhutchinson 30 Oct 11:22 trillian_log_server

I don't expect you to make any code changes in this PR in response to this. But I'm squirting a stream of conciousness into this comment as a TODO to at least raise an issue to discuss this. It could be as simple a solution as docs saying that this binary is the swiss army knife, but if you want a svelte version for a particular environment then copy it and remove the other imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here's an idea: robstradling#5

quota/postgresqlqm/postgresql_quota.go Outdated Show resolved Hide resolved
quota/postgresqlqm/postgresql_quota.go Outdated Show resolved Hide resolved
storage/postgresql/admin_storage.go Outdated Show resolved Hide resolved
storage/postgresql/admin_storage.go Outdated Show resolved Hide resolved
storage/postgresql/admin_storage.go Outdated Show resolved Hide resolved
storage/postgresql/log_storage.go Show resolved Hide resolved
@roger2hk
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

/gcbrun

@mhutchinson
Copy link
Contributor

/gcbrun

Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

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

Looking good. The fact that this is tested and passes the tests means that I'm happy with it. Treat my comments here as largely optional if you want the opportunity to reduce the complexity before you bring up any production logs using this. Apart from the error in CODEOWNERS. That will need to be fixed :-)

CODEOWNERS Outdated Show resolved Hide resolved
storage/postgresql/admin_storage.go Outdated Show resolved Hide resolved
storage/postgresql/tree_storage.go Outdated Show resolved Hide resolved
storage/postgresql/log_storage.go Outdated Show resolved Hide resolved
storage/postgresql/provider.go Outdated Show resolved Hide resolved
storage/postgresql/queue.go Outdated Show resolved Hide resolved
storage/postgresql/schema/storage.sql Outdated Show resolved Hide resolved
storage/postgresql/schema/storage.sql Outdated Show resolved Hide resolved
@mhutchinson
Copy link
Contributor

/gcbrun

Copy link
Contributor

@mhutchinson mhutchinson left a comment

Choose a reason for hiding this comment

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

Woohoo 🎉

@mhutchinson mhutchinson merged commit baa721c into google:master Nov 7, 2024
12 checks passed
@roger2hk
Copy link
Contributor

roger2hk commented Nov 7, 2024

This is super cool to get PostgreSQL in. Thank you so much for the great contribution, @robstradling! (and thanks @mhutchinson for the review)

@robstradling
Copy link
Contributor Author

Thanks @roger2hk. Adding postgres support for your CTFE 'extra data' storage saving feature is next on my list. :-)

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.

3 participants