From eccc47e81c34e8676daf178adbab6ac0d035f347 Mon Sep 17 00:00:00 2001 From: Jay Zhuang Date: Mon, 11 Jan 2021 10:15:59 -0800 Subject: [PATCH] Fix tsan options_test (#7845) Summary: Minor tsan issue that counter could be bumped concurrently: https://app.circleci.com/pipelines/github/facebook/rocksdb/5431/workflows/79312c7c-5815-4f07-8836-94625db8e33e/jobs/81619 Pull Request resolved: https://github.com/facebook/rocksdb/pull/7845 Reviewed By: akankshamahajan15 Differential Revision: D25851472 Pulled By: jay-zhuang fbshipit-source-id: 74cc8797ac503413bec27a30e5d1f055379777e8 --- db/db_options_test.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/db/db_options_test.cc b/db/db_options_test.cc index 0d33cdef0..9036735c6 100644 --- a/db/db_options_test.cc +++ b/db/db_options_test.cc @@ -190,10 +190,11 @@ TEST_F(DBOptionsTest, SetWalBytesPerSync) { options.env = env_; Reopen(options); ASSERT_EQ(512, dbfull()->GetDBOptions().wal_bytes_per_sync); - int counter = 0; + std::atomic_int counter{0}; int low_bytes_per_sync = 0; ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->SetCallBack( - "WritableFileWriter::RangeSync:0", [&](void* /*arg*/) { counter++; }); + "WritableFileWriter::RangeSync:0", + [&](void* /*arg*/) { counter.fetch_add(1); }); ROCKSDB_NAMESPACE::SyncPoint::GetInstance()->EnableProcessing(); const std::string kValue(kValueSize, 'v'); int i = 0;