facebook / facebook/rocksdb

backup fails when used with column family having set cfPaths

Open
#8,263 0 comments 0 reactions 1 assignee Claimed by @adamretter View on GitHub
java-api
Dominant language
C++
Stars
32.1k
Forks
6.9k
Avg merge
32m
Merged PRs (30d)
1

Description

I am using version 6.16.4 rocksdb jar and creating a database with one more column family apart from the default one, on the new column family I am setting cfPath parameter to /tmp, while taking backup it fails and gives

### Expected behavior

### Actual behavior
```
Exception in thread "main" org.rocksdb.RocksDBException: Can not get size for: rocksSample/000035.sst: The system cannot find the file specified.

at org.rocksdb.BackupEngine.createNewBackup(Native Method)
at org.rocksdb.BackupEngine.createNewBackup(BackupEngine.java:84)
at org.example.App.main(App.java:47)
```

the sst file 000035.sst exits in /tmp

### Steps to reproduce the behavior
```java
package org.example;

import org.rocksdb.*;

import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/** Hello world! */
public class App {
public static void main(String[] args) throws RocksDBException {

RocksDB.loadLibrary();

try (final ColumnFamilyOptions cfOpts =
new ColumnFamilyOptions();
final ColumnFamilyOptions inmemory =
new ColumnFamilyOptions().setCfPaths(Arrays.asList(new DbPath(Paths.get("/tmp"),0)))) {

final List cfDescriptors =
Arrays.asList(
new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY, cfOpts),
new ColumnFamilyDescriptor("in memory".getBytes(), inmemory));

final List columnFamilyHandleList = new ArrayList<>();

try (final DBOptions options =
new DBOptions().setCreateIfMissing(true).setCreateMissingColumnFamilies(true).setEnv(Env.getDefault());
final RocksDB db =
RocksDB.open(options, "rocksSample", cfDescriptors, columnFamilyHandleList)) {
ColumnFamilyHandle handle = columnFamilyHandleList.get(1);

try {

for (int i = 0; i < 10000; i++) {
final byte b[] = new Integer(i).toString().getBytes();
db.put(handle, b, b);
}
final File file = new File("C:\\Users\\ArshidDar\\Backup1");
if(file.exists())
file.delete();
file.mkdirs();
try (final BackupableDBOptions bopt = new BackupableDBOptions(file.getAbsolutePath());
final BackupEngine be = BackupEngine.open(options.getEnv(), bopt)) {
be.createNewBackup(db, true);
}
} finally {

for (final ColumnFamilyHandle columnFamilyHandle : columnFamilyHandleList) {
columnFamilyHandle.close();
}
}
}
}
}}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.