Commit 2f2ed86
committed
MB-68916: Fix ep_testsuite_dcp
Some tests in ep_testsuite_dcp spawn a std::thread for running a DCP
client loop that opens DCP producer, issues a StreamRequest and listens
for data.
The problematic part here is in the StreamRequest. The Producer's
stream-map is type folly::AtomicHashArray<> that maps vbid->streams.
That folly type uses a few thread locals internally that end up storing
references to memory that is allocated in the bucket arena in the
EPE::stream_req path. Then std::thread is destroyed outside any bucket
context causing a mem track mismatch at thread's TSD release.
Eg:
% env CB_ARENA_MALLOC_VERIFY_DEALLOC_CLIENT=1 lldb -- ./ep_testsuite_dcp "-E" "ep" "-v" "-e" "compression_mode=active;dbname=./ep_testsuite_dcp.value_eviction.comp_active.db" -C 29
..
Running [29/91]: test producer keep stream open...===ERROR===: JeArenaMalloc deallocation mismatch
Memory freed by client:100 domain:None which is assigned arena:0, but memory was previously allocated from arena:2 (client-specific arena).
Allocation address:0x103dcda40 size:24
..
Process 90807 stopped
* thread #43, name = 'dcp_thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x185e46ae4)
frame #0: 0x0000000185e46ae4 libsystem_c.dylib` __abort + 168
libsystem_c.dylib`:
-> 0x185e46ae4 <+168>: brk #0x1
libsystem_c.dylib`abort_report_np:
0x185e46ae8 <+0>: pacibsp
0x185e46aec <+4>: sub sp, sp, #0x30
0x185e46af0 <+8>: stp x20, x19, [sp, #0x10]
Target 0: (ep_testsuite_dcp) stopped.
(lldb) bt
* thread #43, name = 'dcp_thread', stop reason = EXC_BREAKPOINT (code=1, subcode=0x185e46ae4)
* frame #0: 0x0000000185e46ae4 libsystem_c.dylib` __abort + 168
frame #1: 0x0000000185e46a3c libsystem_c.dylib` abort + 192
frame #2: 0x00000001001d8808 ep_testsuite_dcp` cb::verifyMemDeallocatedByCorrectClient(client=0x0000000171696c78, ptr=0x0000000103dcda40, size=24) + 536 at je_arena_malloc.cc:247
frame #3: 0x00000001001d8898 ep_testsuite_dcp` cb::_JEArenaMalloc<cb::JEArenaSimpleTracker>::sized_free(ptr=0x0000000103dcda40, size=24) + 84 at je_arena_malloc.cc:442
frame #4: 0x00000001000d6dc0 ep_testsuite_dcp` cb::_ArenaMalloc<cb::_JEArenaMalloc<cb::JEArenaSimpleTracker>>::sized_free(ptr=0x0000000103dcda40, size=24) + 32 at cb_arena_malloc.h:273
frame #5: 0x00000001000d6d8c ep_testsuite_dcp` cb_sized_free(ptr=0x0000000103dcda40, size=24) + 44 at cb_malloc_arena.cc:75
frame #6: 0x00000001000d7398 ep_testsuite_dcp` operator delete(ptr=0x0000000103dcda40, size=24) + 32 at global_new_replacement.cc:146
frame #7: 0x000000010081f534 ep_testsuite_dcp` void folly::threadlocal_detail::ElementWrapper::set<folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*>(this=0x0000000171696d33, pt=0x0000000103dcda40, (null)=THIS_THREAD)::'lambda'(void*, folly::TLPDestructionMode)::operator()(void*, folly::TLPDestructionMode) const + 68 at ThreadLocalDetail.h:138
frame #8: 0x000000010081f4e4 ep_testsuite_dcp` void folly::threadlocal_detail::ElementWrapper::set<folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*>(folly::ThreadCachedInt<unsigned long long, unsigned long long>::IntCache*)::'lambda'(void*, folly::TLPDestructionMode)::__invoke(pt=0x0000000103dcda40, (null)=THIS_THREAD) + 36 at ThreadLocalDetail.h:137
frame #9: 0x0000000100168e90 ep_testsuite_dcp` folly::threadlocal_detail::ElementWrapper::dispose(this=0x000000011f7053c8, mode=THIS_THREAD) + 324 at ThreadLocalDetail.h:114
frame #10: 0x0000000100cd0758 ep_testsuite_dcp` folly::threadlocal_detail::StaticMetaBase::onThreadExit(ptr=0x0000000103dd1800) + 404 at ThreadLocalDetail.cpp:153
frame #11: 0x0000000185f37870 libsystem_pthread.dylib` _pthread_tsd_cleanup + 488
frame #12: 0x0000000185f3a684 libsystem_pthread.dylib` _pthread_exit + 84
frame #13: 0x0000000185f39fa0 libsystem_pthread.dylib` _pthread_start + 148
Fix by executing DcpOpen+StreamRequest in the main test thread. All
memcached/bucket resources are released before the main thread shuts down.
Notes:
- That is a test-only issue, no production bug addressed here
- Patch verified locally by
https://review.couchbase.org/c/platform/+/234973, which is being
submitted after all related failures are fixed
Change-Id: Ida20abef00daddb8da4d65305316eba7baccaec7
Reviewed-on: https://review.couchbase.org/c/kv_engine/+/235361
Tested-by: Build Bot <[email protected]>
Well-Formed: Restriction Checker
Reviewed-by: Jim Walker <[email protected]>1 parent 865921e commit 2f2ed86
1 file changed
+56
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
239 | 241 | | |
240 | 242 | | |
241 | 243 | | |
| |||
399 | 401 | | |
400 | 402 | | |
401 | 403 | | |
402 | | - | |
| 404 | + | |
403 | 405 | | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
408 | | - | |
409 | | - | |
| 406 | + | |
410 | 407 | | |
411 | 408 | | |
412 | 409 | | |
413 | 410 | | |
414 | 411 | | |
415 | 412 | | |
416 | | - | |
417 | 413 | | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
2133 | 2135 | | |
2134 | 2136 | | |
2135 | 2137 | | |
2136 | | - | |
| 2138 | + | |
2137 | 2139 | | |
2138 | 2140 | | |
2139 | 2141 | | |
| |||
2397 | 2399 | | |
2398 | 2400 | | |
2399 | 2401 | | |
| 2402 | + | |
2400 | 2403 | | |
2401 | 2404 | | |
2402 | 2405 | | |
| |||
2540 | 2543 | | |
2541 | 2544 | | |
2542 | 2545 | | |
2543 | | - | |
2544 | | - | |
2545 | | - | |
2546 | | - | |
2547 | | - | |
2548 | | - | |
2549 | | - | |
2550 | | - | |
2551 | | - | |
2552 | | - | |
2553 | | - | |
2554 | | - | |
| 2546 | + | |
| 2547 | + | |
| 2548 | + | |
| 2549 | + | |
| 2550 | + | |
| 2551 | + | |
| 2552 | + | |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
2555 | 2556 | | |
2556 | 2557 | | |
2557 | 2558 | | |
| |||
2668 | 2669 | | |
2669 | 2670 | | |
2670 | 2671 | | |
2671 | | - | |
2672 | | - | |
2673 | | - | |
2674 | | - | |
2675 | | - | |
2676 | | - | |
2677 | | - | |
2678 | | - | |
2679 | | - | |
2680 | | - | |
2681 | | - | |
2682 | | - | |
| 2672 | + | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
2683 | 2682 | | |
2684 | 2683 | | |
2685 | 2684 | | |
| |||
2745 | 2744 | | |
2746 | 2745 | | |
2747 | 2746 | | |
2748 | | - | |
2749 | | - | |
2750 | | - | |
2751 | | - | |
2752 | | - | |
2753 | | - | |
2754 | | - | |
2755 | | - | |
2756 | | - | |
2757 | | - | |
2758 | | - | |
2759 | | - | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
| 2752 | + | |
| 2753 | + | |
| 2754 | + | |
| 2755 | + | |
| 2756 | + | |
2760 | 2757 | | |
2761 | 2758 | | |
2762 | 2759 | | |
| |||
5754 | 5751 | | |
5755 | 5752 | | |
5756 | 5753 | | |
| 5754 | + | |
5757 | 5755 | | |
5758 | 5756 | | |
5759 | 5757 | | |
| |||
5838 | 5836 | | |
5839 | 5837 | | |
5840 | 5838 | | |
5841 | | - | |
| 5839 | + | |
5842 | 5840 | | |
5843 | 5841 | | |
5844 | 5842 | | |
| |||
7025 | 7023 | | |
7026 | 7024 | | |
7027 | 7025 | | |
| 7026 | + | |
7028 | 7027 | | |
7029 | 7028 | | |
7030 | | - | |
7031 | | - | |
7032 | | - | |
7033 | | - | |
7034 | | - | |
7035 | | - | |
7036 | | - | |
7037 | | - | |
7038 | | - | |
7039 | | - | |
7040 | | - | |
7041 | | - | |
| 7029 | + | |
| 7030 | + | |
| 7031 | + | |
| 7032 | + | |
| 7033 | + | |
| 7034 | + | |
| 7035 | + | |
| 7036 | + | |
| 7037 | + | |
| 7038 | + | |
7042 | 7039 | | |
7043 | 7040 | | |
7044 | 7041 | | |
| |||
7859 | 7856 | | |
7860 | 7857 | | |
7861 | 7858 | | |
| 7859 | + | |
7862 | 7860 | | |
7863 | 7861 | | |
7864 | 7862 | | |
| |||
0 commit comments