-
Notifications
You must be signed in to change notification settings - Fork 4k
encryption: add support for encryption to writeFileSyncing.
#25281
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
Conversation
e8a95cc to
63e1735
Compare
|
Woohoo, this is looking really good. The one piece of feedback so far—I haven't reviewed in detail yet—is to extract the AppendFile and CloseFile methods into a separate object. Roughly: type Engine interface {
OpenFile() (DBFile, error)
}
type DBFile interface {
AppendFile(contents []byte) error
CloseFile() error
}
type rocksdbFile struct {
rdb *RocksDB
}
func (f *rocksdbFile) AppendFile(contents []byte) error {
return C.DBEnvAppendFile(f.rdb, contents)
}(This example is missing a lot of specifics, of course.) That way you only need to add one method, OpenFile, to the Engine interface. Unless there's a reason you didn't take this approach to begin with? |
bf5085c to
9df1c34
Compare
|
Reviewed 17 of 17 files at r1. pkg/storage/syncing_write.go, line 110 at r1 (raw file):
This call to @dt What's the best way to test that we don't introduce performance regressions here? pkg/storage/engine/engine.go, line 36 at r1 (raw file):
We try not to duplicate all these headers in so many places. Also, Comments from Reviewable |
1bf2c23 to
a037835
Compare
|
@mberhault , Hey Marc, do you mind taking a look at this PR and let me know if I'm on the right track? Thank you. |
mberhault
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. I think a small benchmark comparing regular vs through-libroach writes would be good (one using an in-mem env, and one using actual disk).
c-deps/libroach/engine.cc
Outdated
| std::string rest = ToString(path); | ||
| int i = 0; | ||
| int next; | ||
| while(rest.length() != 0 && (next = rest.find(delimiter)) != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sure to run make c-deps-fmt, or clang-format directly, or add clang-format to your editor save hook for .cc and .h files.
c-deps/libroach/engine.cc
Outdated
|
|
||
| // EnvOpenFile opens a new file in the given engine. | ||
| DBStatus DBImpl::EnvOpenFile(DBSlice path, rocksdb::WritableFile** file) { | ||
| rocksdb::Status s; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: we tend to use the full word status for clarity.
c-deps/libroach/engine.cc
Outdated
| DBStatus DBImpl::EnvAppendFile(rocksdb::WritableFile** file, DBSlice contents) { | ||
| rocksdb::Status s; | ||
| s = (*file)->Append(ToSlice(contents)); | ||
| if (!s.ok()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all the if (!s.ok()) { return ToDBStatus(s); } return kSuccess; calls, you can just return ToDBStatus(s).
|
Review status: 3 of 18 files reviewed at latest revision, 5 unresolved discussions. pkg/storage/syncing_write.go, line 110 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
looks like it was re-added back so I'm 👍 here, but to answer w.r.t. testing: Comments from Reviewable |
|
Reviewed 16 of 16 files at r2. c-deps/libroach/engine.h, line 46 at r2 (raw file):
c-deps/libroach/engine.cc, line 233 at r2 (raw file):
Not true on windows. Does rocksdb have a function we could use that does the right thing here (either to parse a string into directories or take a string and create multiple directories at once)? pkg/storage/client_raft_test.go, line 1142 at r2 (raw file):
Why is this added to this test? pkg/storage/client_replica_gc_test.go, line 75 at r2 (raw file):
And here? pkg/storage/replica_sideload_test.go, line 111 at r2 (raw file):
It would be nice to factor out some of the new repetition in this file. pkg/storage/engine/rocksdb.go, line 2623 at r2 (raw file):
Uncomment or remove this before merging. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 11 unresolved discussions. c-deps/libroach/engine.cc, line 233 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I didn't find any method on the RocksDB side that does the job. I also asked Marc and we agreed to write the recursive directory creation method on our own. Do you have any suggestions on how to work around it, Ben? I feel like adding support for both Windows and Linux could cause a mess. pkg/storage/client_raft_test.go, line 1142 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
It's because if not, the test will use InMem RocksDB, which does not have access to the disk. pkg/storage/client_replica_gc_test.go, line 75 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Same reason as above. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 11 unresolved discussions. c-deps/libroach/engine.cc, line 233 at r2 (raw file): Previously, windchan7 (Victor Chen) wrote…
I saw that you had some commented-out code to create the directory from Go. That would be the simplest thing; is there some reason we can't use it? pkg/storage/client_raft_test.go, line 1142 at r2 (raw file): Previously, windchan7 (Victor Chen) wrote…
Why does it need access to the disk now but it didn't before? If we can't mock everything out in memory, I'd rather change multiTestContext so that all the tests use on-disk rocksdb instead of having a few tests work differently. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 11 unresolved discussions. c-deps/libroach/engine.cc, line 233 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
It's mainly because the pkg/storage/client_raft_test.go, line 1142 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Before the changes, writeFileSyncing always writes to disk regardless its inMem or on disk RocksDB. However, since we want everything to be written to RocksDB's env, inMem env won't be able to write to disk so the checks in the tests will fail if we still use inMem RocksDB. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 11 unresolved discussions. c-deps/libroach/engine.cc, line 233 at r2 (raw file): Previously, windchan7 (Victor Chen) wrote…
What do you mean it won't notice there's a directory on disk already? Are the Go and C++ sides looking at the same path? pkg/storage/client_raft_test.go, line 1142 at r2 (raw file): Previously, windchan7 (Victor Chen) wrote…
Why don't other tests in this file need this too? I don't like having a couple of tests with a 20-line copy-pasted block of boilerplate. We should either support these methods on InMem RocksDB engines or move multiTestContext to use on-disk rocksdb in all cases. Comments from Reviewable |
|
Commenting out Will uncomment it when the issue is resolved before merging. |
|
Review status: 2 of 18 files reviewed at latest revision, 11 unresolved discussions. c-deps/libroach/engine.h, line 46 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. c-deps/libroach/engine.cc, line 228 at r2 (raw file): Previously, mberhault (marc) wrote…
Done. c-deps/libroach/engine.cc, line 233 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. c-deps/libroach/engine.cc, line 238 at r2 (raw file): Previously, mberhault (marc) wrote…
Done. c-deps/libroach/engine.cc, line 269 at r2 (raw file): Previously, mberhault (marc) wrote…
Changed at necessary places. pkg/storage/client_raft_test.go, line 1142 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I made all multiTestContext using on disk engines. Thanks for the suggestion. pkg/storage/replica_sideload_test.go, line 111 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/engine/engine.go, line 36 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. pkg/storage/engine/rocksdb.go, line 2623 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Done. Comments from Reviewable |
|
@mberhault Is it ready to go? I'm holding off merging it until the flaky test get resolved. But feel free to comment on the rest of it. |
6b76263 to
2a51430
Compare
c-deps/libroach/engine.cc
Outdated
| const rocksdb::EnvOptions soptions; | ||
| rocksdb::unique_ptr<rocksdb::WritableFile> rocksdb_file; | ||
|
|
||
| /* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be removed now.
| if (!status.ok()) { | ||
| return ToDBStatus(status); | ||
| } | ||
| delete file; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file object still needs to be deleted on error from Close, or we'll be leaking memory.
|
@mberhault Updated. Thanks a lot! |
4f6bbd1 to
4add11a
Compare
Fixes cockroachdb#25430. Before this change, the `RaftTickInterval` in the test was so low that node liveness only had a few milliseconds to perform updates. This caused the test to be flaky, especially in cockroachdb#25281, which is slowing down all tests by changing from in-memory stores to on-disk stores. By bumping up the `RaftTickInterval` by an order of magnitude in the test, we give node liveness much more time to perform updates. Release note: None
25642: storage: bump RaftTickInterval in TestReplicaLazyLoad r=nvanbenschoten a=nvanbenschoten Fixes #25430. Before this change, the `RaftTickInterval` in the test was so low that node liveness only had a few milliseconds to perform updates. This caused the test to be flaky, especially in #25281, which is slowing down all tests by changing from in-memory stores to on-disk stores. By bumping up the `RaftTickInterval` by an order of magnitude in the test, we give node liveness much more time to perform updates. Release note: None Co-authored-by: Nathan VanBenschoten <nvanbenschoten@gmail.com>
`writeFileSyncing()` now will be able to write encrypted content to RocksDB's env. This commit is part of `use encryption for all local disk usage (non-logs)`. Issue: cockroachdb#19783. Release note: None
|
@mberhault Now the flaky test is resolved. |
mberhault
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
bors r+ |
25281: encryption: add support for encryption to `writeFileSyncing`. r=windchan7 a=windchan7 `writeFileSyncing()` now will be able to write encrypted content to RocksDB's env. This commit is part of `use encryption for all local disk usage (non-logs)`. Issue: #19783. Release note: None Co-authored-by: Victor Chen <victor@cockroachlabs.com>
Build succeeded |
writeFileSyncing()now will be able to write encrypted content to RocksDB'senv. This commit is part of
use encryption for all local disk usage (non-logs).Issue: #19783.
Release note: None