heguanhui opened a new pull request, #63928:
URL: https://github.com/apache/doris/pull/63928
### What problem does this PR solve?
Issue Number: close #63927
Problem Summary: Building BE unit tests with TSAN (`-O1`) or RELEASE (`-O3`)
causes undefined reference linker errors for `SegmentWriter::_is_mow()`,
`SegmentWriter::_is_mow_with_cluster_key()`, and their `VerticalSegmentWriter`
counterparts.
**Root cause**: Commit `74aa0ca63a` defined these methods with the `inline`
keyword in `.cpp` files (`segment_writer.cpp` and
`vertical_segment_writer.cpp`). At `-O0` (ASAN), the compiler ignores `inline`
and exports the symbol, so linking succeeds. At `-O1`/`-O3`, the compiler
inlines the function and does NOT export the symbol. When commit `4616202fc4`
introduced `TestSegmentWriter` (a friend subclass) in `test_segment_writer.h`
that calls these private methods from a different translation unit, the linker
cannot find the symbols.
**Fix**: Move the `inline` definitions from `.cpp` files into the header
files as class-internal inline definitions, so they are visible to all
translation units.
**Error example** (TSAN build):
```
undefined reference to 'doris::segment_v2::SegmentWriter::_is_mow()'
undefined reference to
'doris::segment_v2::SegmentWriter::_is_mow_with_cluster_key()'
undefined reference to 'doris::segment_v2::VerticalSegmentWriter::_is_mow()'
undefined reference to
'doris::segment_v2::VerticalSegmentWriter::_is_mow_with_cluster_key()'
```
### Release note
None
### Check List (For Author)
- Test
- [x] Unit Test: Added `segment_writer_mow_check_test.cpp` with 7 test
cases covering all logic branches for both `SegmentWriter` and
`VerticalSegmentWriter`
- [ ] Regression test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]