Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/rocksdb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ rocksdb__on_open(uv_work_t *handle) {

auto env = NewCompositeEnv(std::make_shared<rocksdb_file_system_t>());

options.env = env.release();
options.env = env.get();

auto handles = std::vector<ColumnFamilyHandle *>(req->len);

Expand Down Expand Up @@ -1124,6 +1124,8 @@ rocksdb__on_open(uv_work_t *handle) {
db->read_only = read_only;

if (status.ok()) {
env.release();

db->handle = ptr.release();
db->lock = lock;

Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ list(APPEND tests
open-close
open-close-immediately
open-close-sync
open-locked
read-only-wal-filter
write-flush
write-read
Expand Down
48 changes: 48 additions & 0 deletions test/open-locked.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <assert.h>
#include <stdbool.h>
#include <uv.h>

#include "../include/rocksdb.h"

int
main() {
int e;

uv_loop_t *loop = uv_default_loop();

rocksdb_options_t options = {
.create_if_missing = true,
};

rocksdb_column_family_descriptor_t descriptor = rocksdb_column_family_descriptor("default", NULL);

rocksdb_t db;
rocksdb_column_family_t *family;

rocksdb_open_t open;
e = rocksdb_open(loop, &db, &open, "test/fixtures/open-locked.db", &options, &descriptor, &family, 1, NULL, NULL);
assert(e == 0);
assert(open.error == NULL);
rocksdb_open_cleanup(&open);

// Fails on the lock held by the first open.
{
rocksdb_t db;
rocksdb_column_family_t *family;

rocksdb_open_t open;
e = rocksdb_open(loop, &db, &open, "test/fixtures/open-locked.db", &options, &descriptor, &family, 1, NULL, NULL);
assert(e == 0);
assert(open.error != NULL);
rocksdb_open_cleanup(&open);
}

e = rocksdb_column_family_destroy(&db, family);
assert(e == 0);

rocksdb_close_t close;
e = rocksdb_close(&db, &close, NULL, NULL);
assert(e == 0);
assert(close.error == NULL);
rocksdb_close_cleanup(&close);
}
Loading