From 89429a90811f0fb57a024d384948abc936f9a227 Mon Sep 17 00:00:00 2001 From: gukaifeng Date: Tue, 15 Mar 2022 09:55:49 -0700 Subject: [PATCH] fix a bug of the ticker NO_FILE_OPENS (#9677) Summary: In the original code, the value of `NO_FILE_OPENS` corresponding to the Ticker item will be increased regardless of whether the file is successfully opened or not. Even counts are repeated, which can lead to skewed counts. Pull Request resolved: https://github.com/facebook/rocksdb/pull/9677 Reviewed By: jay-zhuang Differential Revision: D34725733 Pulled By: ajkr fbshipit-source-id: 841234ed03802c0105fd2107d82a740265ead576 --- db/table_cache.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/db/table_cache.cc b/db/table_cache.cc index c86f60750..e548fc6c3 100644 --- a/db/table_cache.cc +++ b/db/table_cache.cc @@ -114,15 +114,18 @@ Status TableCache::GetTableReader( if (s.ok()) { s = ioptions_.fs->NewRandomAccessFile(fname, fopts, &file, nullptr); } - RecordTick(ioptions_.stats, NO_FILE_OPENS); - if (s.IsPathNotFound()) { + if (s.ok()) { + RecordTick(ioptions_.stats, NO_FILE_OPENS); + } else if (s.IsPathNotFound()) { fname = Rocks2LevelTableFileName(fname); s = PrepareIOFromReadOptions(ro, ioptions_.clock, fopts.io_options); if (s.ok()) { s = ioptions_.fs->NewRandomAccessFile(fname, file_options, &file, nullptr); } - RecordTick(ioptions_.stats, NO_FILE_OPENS); + if (s.ok()) { + RecordTick(ioptions_.stats, NO_FILE_OPENS); + } } if (s.ok()) {