Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
54308: storage: fix encryption-at-rest on RocksDB r=petermattis a=petermattis

29cb28d accidentally broke
encryption-at-rest on RocksDB by removing the call to
`SetRocksDBOpenHook(C.DBOpenHookCCL)`.

Fixes cockroachdb#54300

Release note: none

Co-authored-by: Peter Mattis <[email protected]>
  • Loading branch information
craig[bot] and petermattis committed Sep 12, 2020
2 parents 2a11415 + 7619a70 commit 38115d0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
28 changes: 28 additions & 0 deletions pkg/ccl/storageccl/engineccl/rocksdb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright 2017 The Cockroach Authors.
//
// Licensed as a CockroachDB Enterprise file under the Cockroach Community
// License (the "License"); you may not use this file except in compliance with
// the License. You may obtain a copy of the License at
//
// https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt

package engineccl

import "github.com/cockroachdb/cockroach/pkg/storage"

// #cgo CPPFLAGS: -I../../../../c-deps/libroach/include -I../../../../c-deps/libroach/ccl/include
// #cgo LDFLAGS: -lroachccl
// #cgo LDFLAGS: -lroach
// #cgo LDFLAGS: -lprotobuf
// #cgo LDFLAGS: -lrocksdb
// #cgo LDFLAGS: -lsnappy
// #cgo LDFLAGS: -lcryptopp
// #cgo linux LDFLAGS: -lrt -lpthread
// #cgo windows LDFLAGS: -lshlwapi -lrpcrt4
//
// #include <libroachccl.h>
import "C"

func init() {
storage.SetRocksDBOpenHook(C.DBOpenHookCCL)
}
6 changes: 6 additions & 0 deletions pkg/storage/rocksdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ type RocksDBCache struct {
cache *C.DBCache
}

// SetRocksDBOpenHook sets the DBOpenHook function that will be called during
// RocksDB initialization. It is intended to be called by CCL code.
func SetRocksDBOpenHook(fn unsafe.Pointer) {
C.DBSetOpenHook(fn)
}

// NewRocksDBCache creates a new cache of the specified size. Note that the
// cache is refcounted internally and starts out with a refcount of one (i.e.
// Release() should be called after having used the cache).
Expand Down

0 comments on commit 38115d0

Please sign in to comment.