Skip to content

cachelib shutdown error.  #382

@awzhgw

Description

@awzhgw
W0418 18:53:24.114425 276070 ExceptionTracer.cpp:187] Invalid trace stack for exception of type: std::invalid_argument
terminate called after throwing an instance of 'std::invalid_argument'
  what():  shutDown can only be called once from a cached manager created on shared memory. You may also be incorrectly constructing your allocator. Are you passing in AllocatorType::SharedMem* ?
SIGABRT: abort

When I call cache->shutDown, an error occurs. My initialization configuration is as follows:

void RocksCachelibWrapper::Close() {
  FbCache* cache = cache_.load();
  if (!cache){
    return;
  }
  auto res = cache->shutDown();
  if (res == FbCache::ShutDownStatus::kSuccess) {
    std::cout << "Cachelib shut down successfully" << std::endl;
  }
  delete cache;
}
std::unique_ptr<rocksdb::SecondaryCache> NewRocksCachelibWrapper(
    const RocksCachelibOptions& opts) {
  std::unique_ptr<FbCache> cache;
  cachelib::PoolId defaultPool;
  FbCacheConfig config;
  NvmCacheConfig nvmConfig;

  nvmConfig.navyConfig.setBlockSize(opts.blockSize);
  nvmConfig.navyConfig.setSimpleFile(opts.fileName, opts.size,
                                     /*truncateFile=*/false);
  nvmConfig.navyConfig.setReaderAndWriterThreads(opts.readerThreads, opts.writerThreads);
  nvmConfig.navyConfig.setMaxConcurrentInserts(opts.maxConcurrentInserts);
  nvmConfig.navyConfig.setMaxParcelMemoryMB(opts.maxParcelMemoryMB);

  nvmConfig.navyConfig.blockCache().setRegionSize(opts.regionSize);

  if (opts.evictionPolicy == "FIFO") {
    nvmConfig.navyConfig.blockCache().enableFifo();
  } else if (opts.sFifoSegmentRatio.size() != 0) {
    nvmConfig.navyConfig.blockCache().enableSegmentedFifo(
        opts.sFifoSegmentRatio);
  }
  if (opts.hitsBaseReinsertionThreshold > 0) {
    nvmConfig.navyConfig.blockCache().enableHitsBasedReinsertion(
        opts.hitsBaseReinsertionThreshold);
  } else if (opts.pctBaseReinsertionThreshold > 0) {
    nvmConfig.navyConfig.blockCache().enablePctBasedReinsertion(
        opts.pctBaseReinsertionThreshold);
  }

  if (opts.dataChecksum == false) {
    nvmConfig.navyConfig.blockCache().setDataChecksum(false);
  }

  if (opts.bigHashSizePct != 0) {
    nvmConfig.navyConfig.bigHash()
        .setSizePctAndMaxItemSize(opts.bigHashSizePct, 2048)
        .setBucketSize(opts.bucketSize)
        .setBucketBfSize(opts.bucketBfSize);
  }

  if (opts.admPolicy == "random") {
    nvmConfig.navyConfig.enableRandomAdmPolicy().setAdmProbability(
        opts.admProbability);
  } else {
    nvmConfig.navyConfig.enableDynamicRandomAdmPolicy()
        .setMaxWriteRate(opts.maxWriteRate)
        .setAdmWriteRate(opts.admissionWriteRate);
  }
  config.setCacheSize(opts.volatileSize)
      .setCacheName(opts.cacheName)
      .enableNvmCache(nvmConfig)
      .enableCachePersistence(opts.cacheDir)
      .usePosixForShm()
      .setAccessConfig(
          {opts.bktPower /* bucket power */, opts.lockPower /* lock power */})
      .validate();  // will throw if bad config
  try{
    cache = std::make_unique<FbCache>(FbCache::SharedMemAttach,config);
  }catch (const std::exception& ex) {
    cache.reset();
    std::cout << "Couldn't attach to cache: " << ex.what() << std::endl;
    cache = std::make_unique<FbCache>(FbCache::SharedMemNew, config);
  }
  defaultPool =
      cache->addPool("default", cache->getCacheMemoryStats().ramCacheSize);

  return std::unique_ptr<rocksdb::SecondaryCache>(
      new RocksCachelibWrapper(std::move(cache), std::move(defaultPool)));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions