Fix failure in c_test (#9547)

Summary:
When tests are run with TMPD, c_test may fail because TMPD
is not created by the test. It results in IO error: No such file
or directory: While mkdir if missing:
/tmp/rocksdb_test_tmp/rocksdb_c_test-0: No such file or directory

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9547

Test Plan:
make -j32 c_test;
 TEST_TMPDIR=/tmp/rocksdb_test  ./c_test

Reviewed By: riversand963

Differential Revision: D34173298

Pulled By: akankshamahajan15

fbshipit-source-id: 5b5a01f5b842c2487b05b0708c8e9532241db7f8
main
Akanksha Mahajan 2 years ago committed by Facebook GitHub Bot
parent 95d9cb8357
commit 5c53b9008f
  1. 1
      HISTORY.md
  2. 5
      db/c.cc
  3. 4
      db/c_test.c
  4. 2
      include/rocksdb/c.h

@ -70,6 +70,7 @@
* Introduced an option `BlockBasedTableBuilder::detect_filter_construct_corruption` for detecting corruption during Bloom Filter (format_version >= 5) and Ribbon Filter construction.
* Improved the SstDumpTool to read the comparator from table properties and use it to read the SST File.
* Extended the column family statistics in the info log so the total amount of garbage in the blob files and the blob file space amplification factor are also logged. Also exposed the blob file space amp via the `rocksdb.blob-stats` DB property.
* Introduced the API rocksdb_create_dir_if_missing in c.h that calls underlying file system's CreateDirIfMissing API to create the directory.
## 6.29.0 (01/21/2022)
Note: The next release will be major release 7.0. See https://github.com/facebook/rocksdb/issues/9390 for more info.

@ -4321,6 +4321,11 @@ rocksdb_sstfilewriter_t* rocksdb_sstfilewriter_create(
return writer;
}
void rocksdb_create_dir_if_missing(rocksdb_env_t* env, const char* path,
char** errptr) {
SaveError(errptr, env->rep->CreateDirIfMissing(std::string(path)));
}
rocksdb_sstfilewriter_t* rocksdb_sstfilewriter_create_with_comparator(
const rocksdb_envoptions_t* env, const rocksdb_options_t* io_options,
const rocksdb_comparator_t* /*comparator*/) {

@ -447,6 +447,10 @@ int main(int argc, char** argv) {
cmp = rocksdb_comparator_create(NULL, CmpDestroy, CmpCompare, CmpName);
dbpath = rocksdb_dbpath_create(dbpathname, 1024 * 1024);
env = rocksdb_create_default_env();
rocksdb_create_dir_if_missing(env, GetTempDir(), &err);
CheckNoError(err);
cache = rocksdb_cache_create_lru(100000);
options = rocksdb_options_create();

@ -1818,6 +1818,8 @@ extern ROCKSDB_LIBRARY_API rocksdb_envoptions_t* rocksdb_envoptions_create(
void);
extern ROCKSDB_LIBRARY_API void rocksdb_envoptions_destroy(
rocksdb_envoptions_t* opt);
extern ROCKSDB_LIBRARY_API void rocksdb_create_dir_if_missing(
rocksdb_env_t* env, const char* path, char** errptr);
/* SstFile */

Loading…
Cancel
Save