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

added/updated postgresql implementation of log_storage #1571

Merged
merged 36 commits into from
May 21, 2019
Merged

added/updated postgresql implementation of log_storage #1571

merged 36 commits into from
May 21, 2019

Conversation

bigjimnolan
Copy link
Contributor

@bigjimnolan bigjimnolan commented May 9, 2019

I have added the code to use the log_storage with postgres. This allows a third storage solution for the base set. I have not updated or implemented the map storage code yet, however.

Contributes to #1298.

Checklist

@codecov
Copy link

codecov bot commented May 9, 2019

Codecov Report

Merging #1571 into master will increase coverage by 0.82%.
The diff coverage is 61.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1571      +/-   ##
==========================================
+ Coverage   66.89%   67.71%   +0.82%     
==========================================
  Files         110      111       +1     
  Lines        8946     9529     +583     
==========================================
+ Hits         5984     6453     +469     
- Misses       2358     2383      +25     
- Partials      604      693      +89
Impacted Files Coverage Δ
server/postgres_storage_provider.go 4.16% <0%> (-0.19%) ⬇️
storage/postgres/queue.go 42% <42%> (ø)
storage/postgres/tree_storage.go 55.35% <51.61%> (+48.14%) ⬆️
storage/postgres/log_storage.go 64.4% <64.4%> (ø)
log/sequencer.go 74.89% <0%> (ø) ⬆️
testonly/compact_merkle_tree.go
merkle/compact/tree.go 89.83% <0%> (+0.64%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c3b56b5...3ff3939. Read the comment docs.

Copy link
Contributor

@RJPercival RJPercival left a comment

Choose a reason for hiding this comment

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

Could you add test coverage please?

server/postgres_storage_provider.go Outdated Show resolved Hide resolved
storage/postgres/tree_storage.go Show resolved Hide resolved
storage/postgres/tree_storage.go Outdated Show resolved Hide resolved
storage/postgres/testdb/testdb.go Outdated Show resolved Hide resolved
storage/postgres/testdb/testdb.go Outdated Show resolved Hide resolved
storage/postgres/testdb/testdb.go Show resolved Hide resolved
Copy link
Member

@AlCutter AlCutter left a comment

Choose a reason for hiding this comment

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

Thanks for sending this!

A few comments from a quick pass over.

storage/postgres/storage_unsafe.sql Outdated Show resolved Hide resolved
storage/postgres/storage_unsafe.sql Outdated Show resolved Hide resolved
storage/postgres/log_storage.go Outdated Show resolved Hide resolved
storage/postgres/log_storage.go Show resolved Hide resolved
storage/postgres/log_storage.go Outdated Show resolved Hide resolved
storage/postgres/log_storage.go Outdated Show resolved Hide resolved
storage/postgres/storage_unsafe.sql Outdated Show resolved Hide resolved
storage/postgres/storage_unsafe.sql Outdated Show resolved Hide resolved
storage/postgres/tree_storage.go Outdated Show resolved Hide resolved
storage/postgres/tree_storage.go Show resolved Hide resolved
@bigjimnolan
Copy link
Contributor Author

The CI keeps failing on a goimports failure on a file I didn't edit. Can anyone offer advice on what's going on?

@AlCutter
Copy link
Member

You can just run the goimports tool on that file and it should fix it for you

@bigjimnolan
Copy link
Contributor Author

bigjimnolan commented May 10, 2019

I absolutely agree that goimports should fix this issue. I don't think we're working with the same version. When I run goimports on an old version of the file, I get:

bigjim@CTDev:~/go/src/github.com/google/t2/server/admin$ goimports -d admin_server_test.go
diff -u admin_server_test.go.orig admin_server_test.go
--- admin_server_test.go.orig   2019-05-10 17:02:50.239530377 +0000
+++ admin_server_test.go        2019-05-10 17:02:50.239530377 +0000
@@ -596,8 +596,8 @@
        for _, test := range tests {
                setup := setupAdminServer(
                        ctrl,
-                       nil,                       /* keygen */
-                       false,                     /* snapshot */
+                       nil,   /* keygen */
+                       false, /* snapshot */
                        test.wantCode == codes.OK, /* shouldCommit */
                        false /* commitErr */)
                s := setup.server
@@ -810,8 +810,8 @@
        for _, test := range tests {
                setup := setupAdminServer(
                        ctrl,
-                       nil,                   /* keygen */
-                       false,                 /* snapshot */
+                       nil,   /* keygen */
+                       false, /* snapshot */
                        test.deleteErr == nil, /* shouldCommit */
                        test.commitErr /* commitErr */)
                req := &trillian.DeleteTreeRequest{TreeId: 10}
@@ -897,8 +897,8 @@
        for _, test := range tests {
                setup := setupAdminServer(
                        ctrl,
-                       nil,                     /* keygen */
-                       false,                   /* snapshot */
+                       nil,   /* keygen */
+                       false, /* snapshot */
                        test.undeleteErr == nil, /* shouldCommit */
                        test.commitErr /* commitErr */)
                req := &trillian.UndeleteTreeRequest{TreeId: 10}

It seems to loathe the tabs and wants spaces. However, when I run it on the file that autobuild is complaining about, I get no response:

bigjim@CTDev:~/new_trillian/trillian/server/admin$ goimports -d admin_server_test.go
bigjim@CTDev:~/new_trillian/trillian/server/admin$

Indicating, to me, at least that the code is fine. However, the build version of the formatter does not agree; even after removing the tabs. I have been able to get further by deleting the comments, but I don't think that's a nice thing to do with someone else's code. What is the issue with the comments?

@RJPercival RJPercival assigned RJPercival and AlCutter and unassigned bigjimnolan May 14, 2019
@AlCutter
Copy link
Member

Cool, can you put a Big Scary Warning™ (perhaps a comment and a log.Warning()) in here somewhere about it being experimental code and very likely to eat ones cat, etc. if used?

@bigjimnolan
Copy link
Contributor Author

I have put it in the logs as a warning when people use the PostgreSQL log storage provider.

Copy link
Member

@AlCutter AlCutter left a comment

Choose a reason for hiding this comment

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

@RJPercival you cool?

@AlCutter
Copy link
Member

@RJPercival you cool?

ping @RJPercival

Copy link
Contributor

@RJPercival RJPercival left a comment

Choose a reason for hiding this comment

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

Are the tests mostly copied and pasted from the MySQL tests? If so, it'd be better to refactor into a test suite that can be applied to either the MySQL or Postgres implementations. That'd be fine as a follow-up though.

There appear to be a number of comments from @AlCutter that haven't been resolved yet. Since you've approved already, does that mean you're happy for those to be deferred, @AlCutter?

nil, // keygen
false, // snapshot
test.wantCode == codes.OK,
false)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we lose the comments from some of these lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These comments were causing the server-side goimports to fail. I have no idea why. They checked out just fine on my local side. When I removed them, the autobuild succeeded. I have no problem with someone putting them back in.

storage/postgres/README.md Show resolved Hide resolved
storage/postgres/README.md Outdated Show resolved Hide resolved
storage/postgres/README.md Outdated Show resolved Hide resolved
storage/postgres/storage.sql Outdated Show resolved Hide resolved
storage/postgres/tree_storage.go Show resolved Hide resolved
storage/postgres/storage_test.go Outdated Show resolved Hide resolved
storage/postgres/storage_test.go Outdated Show resolved Hide resolved
storage/postgres/storage_test.go Outdated Show resolved Hide resolved
nodeIDsToRead[i] = nodesToStore[i].NodeID
}

{
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the braces here?

@bigjimnolan
Copy link
Contributor Author

I have lost the ability to see what's different between my storage.sql and the repo's version. Can you please manually resolve those conflicts?

Thanks,

Jim

Copy link
Contributor Author

@bigjimnolan bigjimnolan left a comment

Choose a reason for hiding this comment

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

I've pushed a new version up, but I think we're still jammed up on storage.sql. I have no idea what its looking like on the repo side and I think you even moved it. Can you please make the fixes on your end, so I can re-sync and start pushing through my next series of updates?

Thanks,

Jim

Copy link
Contributor

@RJPercival RJPercival left a comment

Choose a reason for hiding this comment

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

LGTM bar a few unresolved comments and some future cleanup to share code with the MySQL implementation.

reflect "reflect"

gomock "github.com/golang/mock/gomock"
Copy link
Contributor

Choose a reason for hiding this comment

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

Did go generate move this import?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guarantee it did. For some of the directories, I had to run goimports for all the files.

}

func openTestDBOrDie() *sql.DB {
db, err := testdb.NewTrillianDB(context.TODO())
Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the diff for TestMain(), you'll see that it used to create a Context and pass it to testdb.NewTrillianDBOrDie(). You could instead pass the context to openTestDBOrDie().

@RJPercival RJPercival closed this May 20, 2019
@RJPercival
Copy link
Contributor

Oops, tried to push a merge as requested but got the command a little wrong and pushed my master branch onto yours, which happened to be where you were doing your work. Could you re-push your commits to your master branch please?

@bigjimnolan
Copy link
Contributor Author

Can do

@bigjimnolan
Copy link
Contributor Author

Done

@RJPercival RJPercival reopened this May 20, 2019
@bigjimnolan
Copy link
Contributor Author

Hey, I have re-pushed the code and got it through the docker tests ( I think the resource wasn't available last time it rand ) , so we should be good to go now. Thanks,
Jim

@RJPercival RJPercival merged commit a3f4ab2 into google:master May 21, 2019
gdbelvin added a commit that referenced this pull request May 23, 2019
* master: (94 commits)
  Complete TODO (#1632)
  fake_node_reader: Remove unused field (#1631)
  Parallelize VerifyMapLeavesResponse (#1615)
  Remove redundant root hash calculations (#1630)
  sequencer: Consolidate compact.Tree initialization (#1629)
  Remove unused NodeReader method (#1625)
  Fix bazel build (#1627)
  added/updated postgresql implementation of log_storage (#1571)
  Clean up compact.Tree tests (#1622)
  Remove old hash list format from compact.Tree (#1621)
  Mention protoc-gen-doc in README.md
  merkle: Add testonly package with golden hashes (#1620)
  compact: Simplify getting hashes in NewTreeWithState (#1618)
  compact: Implement Tree using Range (#1522)
  Guard verbose logging in merkle path code (#1604)
  Make MaskLeft of NodeID return an explicit copy. (#1612)
  Convert directly from Int.Bits() to NodeID (#1614)
  Couple of changes to make NodeIDs more frugal. (#1613)
  compact.Tree: Change semantic of adding leaves (#1592)
  MapHasher: Do not return error from HashLeaf (#1611)
  ...
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.

4 participants