[Bug] TSAN build fails with undefined symbol: BlockFileCache::get_cell<std::lock_guard<std::mutex>>
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
Research direction
Start in be/src/io/cache/block_file_cache.cpp around the existing remove explicit instantiation, then compare the related LRUQueue instantiations in file_cache_common.cpp. Run bash build.sh --be --ut --tsan and inspect be/test/io/cache/block_file_cache_test.cpp around lines 2976 and 2989. Done means the BE unit-test target links successfully under TSAN and the cache test passes.
Written by the indexing model from the issue text.
Description
Search before asking
- I had searched in the issues and found no similar issues.
Version
master
What's Wrong?
When building BE UT with TSAN, the linker reports an undefined symbol error:
ld.lld: error: undefined symbol: doris::io::FileBlockCell* doris::io::BlockFileCache::get_cell<std::lock_guard<std::mutex>>(doris::io::UInt128Wrapper const&, unsigned long, T&)
>>> referenced by block_file_cache_test.cpp:2976 (./be/ut_build_TSAN/./be/test/io/cache/block_file_cache_test.cpp:2976)
>>> test/CMakeFiles/doris_be_test.dir/io/cache/block_file_cache_test.cpp.o:(doris::io::BlockFileCacheTest_late_holder_remove_skips_replaced_cache_cell_Test::TestBody())
>>> referenced by block_file_cache_test.cpp:2989 (./be/ut_build_TSAN/./be/test/io/cache/block_file_cache_test.cpp:2989)
>>> test/CMakeFiles/doris_be_test.dir/io/cache/block_file_cache_test.cpp.o:(doris::io::BlockFileCacheTest_late_holder_remove_skips_replaced_cache_cell_Test::TestBody())
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
What You Expected?
BE UT should build and link successfully with TSAN enabled.
How to Reproduce?
- Build BE UT with TSAN:
bash build.sh --be --ut --tsan - Linker fails with undefined symbol for
BlockFileCache::get_cell<std::lock_guard<std::mutex>>
Root Cause
BlockFileCache::get_cell is a template function with requires IsXLock<T> constraint, defined in block_file_cache.cpp. It lacks explicit template instantiation for std::lock_guard<std::mutex>. In non-TSAN builds, the compiler may inline the template, masking the issue. TSAN builds disable inlining (instrumentation requires intercepting each function call), exposing the missing symbol.
The same pattern already exists for the remove template function at block_file_cache.cpp:2515:
template void BlockFileCache::remove(FileBlockSPtr file_block,
std::lock_guard<std::mutex>& cache_lock,
std::lock_guard<std::mutex>& block_lock, bool sync);
And for LRUQueue templates in file_cache_common.cpp:149-150:
template size_t LRUQueue::get_capacity(std::lock_guard<std::mutex>& cache_lock) const;
template void LRUQueue::remove(Iterator queue_it, std::lock_guard<std::mutex>& cache_lock);
get_cell is simply missing the same explicit instantiation.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
- Dominant language
- Java
- Stars
- 16k
- Forks
- 4k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 569
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/doris
-
Difficulty 1/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
infinispan/infinispan#18150 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100