From 722870b70c079cd24268e5078055e357199df267 Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 12 Jul 2017 22:11:50 +0200 Subject: [PATCH] fix access to cache object if cache is turned off (#2782) --- arangod/RocksDBEngine/RocksDBEngine.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arangod/RocksDBEngine/RocksDBEngine.cpp b/arangod/RocksDBEngine/RocksDBEngine.cpp index 8146cae047..654862886d 100644 --- a/arangod/RocksDBEngine/RocksDBEngine.cpp +++ b/arangod/RocksDBEngine/RocksDBEngine.cpp @@ -1593,10 +1593,19 @@ void RocksDBEngine::getStatistics(VPackBuilder& builder) const { if (_options.table_factory) { void* options = _options.table_factory->GetOptions(); if (options != nullptr) { - builder.add( - "rocksdb.block-cache-used", - VPackValue(static_cast(options) - ->block_cache->GetUsage())); + auto* bto = static_cast(options); + + if (bto != nullptr && bto->block_cache != nullptr) { + // block cache is present + builder.add( + "rocksdb.block-cache-used", + VPackValue(bto->block_cache->GetUsage())); + } else { + // no block cache present + builder.add( + "rocksdb.block-cache-used", + VPackValue(0)); + } } }