Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](common) implement the move assignment operator for Status #23372

Merged
merged 1 commit into from
Aug 24, 2023

Conversation

AshinGau
Copy link
Member

@AshinGau AshinGau commented Aug 23, 2023

Proposed changes

Status's move assignment operator is a default function, which can't move the unique pointer of _err_msg correctly, and _err_msg may be an uninitialized pointer when assigning OK.
In the process of return value optimization, the move assignment operator will be called, so the following error is thrown when initializing the BE's file cache:

 0# doris::signal::(anonymous namespace)::FailureSignalHandler(int, siginfo_t*, void*) at /mnt/disk1/lidongyang/doris/be/src/common/signal_handler.h:413
 1# os::Linux::chained_handler(int, siginfo_t*, void*) in /usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so
 2# JVM_handle_linux_signal in /usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so
 3# signalHandler(int, siginfo_t*, void*) in /usr/lib/jvm/java-11-openjdk-amd64/lib/server/libjvm.so
 4# 0x00007F0336132090 in /lib/x86_64-linux-gnu/libc.so.6
 5# doris::io::FileCacheFactory::create_file_cache(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, doris::io::FileCacheSettings const&, doris::Status*) at /mnt/disk1/lidongyang/doris/be/src/io/cache/block/block_file_cache_factory.cpp:75
 6# doris::ThreadPool::dispatch_thread() in /root/20230822114947-doris-branch-2_0-9c0138f1ca/be/lib/doris_be
 7# doris::Thread::supervise_thread(void*) at /mnt/disk1/lidongyang/doris/be/src/util/thread.cpp:466
 8# start_thread at /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:478
 9# __clone at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97

Where *status = cache->initialize() will call the move assignment operator, but _err_msg is not a nullptr with unexpected value.

Complete Error Stack in GDB

Thread 43 "FileCacheInitTh" hit Catchpoint 1 (signal SIGSEGV), std::__uniq_ptr_impl<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::reset (this=0x7fffcfc56558, __p=0x0)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:182
182	/mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h: No such file or directory.
(gdb) bt
#0  std::__uniq_ptr_impl<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::reset (this=0x7fffcfc56558, __p=0x0)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:182
#1  std::__uniq_ptr_impl<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::operator= (this=0x7fffcfc56558, __u=...)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:167
#2  std::__uniq_ptr_data<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg>, true, true>::operator= (
    this=0x7fffcfc56558)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:212
#3  std::unique_ptr<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::operator= (this=0x7fffcfc56558)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:371
#4  doris::Status::operator= (this=0x7fffcfc56550, rhs=...) at /mnt/datadisk0/gaoxin/ws/doris/be/src/common/status.h:335
#5  doris::io::FileCacheFactory::create_file_cache (this=0x55556b349190 <doris::io::FileCacheFactory::instance()::ret>,
    cache_base_path=..., file_cache_settings=..., status=0x7fffcfc56550)
    at /mnt/datadisk0/gaoxin/ws/doris/be/src/io/cache/block/block_file_cache_factory.cpp:75
#6  0x000055556104ffbf in doris::ThreadPool::dispatch_thread (this=0x7fffd47a44c0)
    at /mnt/datadisk0/gaoxin/ws/doris/be/src/util/threadpool.cpp:531
#7  0x000055556104725c in std::function<void ()>::operator()() const (this=0x7fffd371c2d8)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
#8  doris::Thread::supervise_thread (arg=0x7fffd3e0ed60) at /mnt/datadisk0/gaoxin/ws/doris/be/src/util/thread.cpp:465
#9  0x00007ffff7c37609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007ffff7ec6133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
(gdb) up 2
#2  std::__uniq_ptr_data<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg>, true, true>::operator= (
    this=0x7fffcfc56558)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:212
212	in /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h
(gdb) up 2
#4  doris::Status::operator= (this=0x7fffcfc56550, rhs=...) at /mnt/datadisk0/gaoxin/ws/doris/be/src/common/status.h:335
335	/mnt/datadisk0/gaoxin/ws/doris/be/src/common/status.h: No such file or directory.
(gdb) bt
#0  std::__uniq_ptr_impl<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::reset (this=0x7fffcfc56558, __p=0x0)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:182
#1  std::__uniq_ptr_impl<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::operator= (this=0x7fffcfc56558, __u=...)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:167
#2  std::__uniq_ptr_data<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg>, true, true>::operator= (
    this=0x7fffcfc56558)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:212
#3  std::unique_ptr<doris::Status::ErrMsg, std::default_delete<doris::Status::ErrMsg> >::operator= (this=0x7fffcfc56558)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/unique_ptr.h:371
#4  doris::Status::operator= (this=0x7fffcfc56550, rhs=...) at /mnt/datadisk0/gaoxin/ws/doris/be/src/common/status.h:335
#5  doris::io::FileCacheFactory::create_file_cache (this=0x55556b349190 <doris::io::FileCacheFactory::instance()::ret>,
    cache_base_path=..., file_cache_settings=..., status=0x7fffcfc56550)
    at /mnt/datadisk0/gaoxin/ws/doris/be/src/io/cache/block/block_file_cache_factory.cpp:75
#6  0x000055556104ffbf in doris::ThreadPool::dispatch_thread (this=0x7fffd47a44c0)
    at /mnt/datadisk0/gaoxin/ws/doris/be/src/util/threadpool.cpp:531
#7  0x000055556104725c in std::function<void ()>::operator()() const (this=0x7fffd371c2d8)
    at /mnt/datadisk0/gaoxin/doris/ldb_toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560
#8  doris::Thread::supervise_thread (arg=0x7fffd3e0ed60) at /mnt/datadisk0/gaoxin/ws/doris/be/src/util/thread.cpp:465
#9  0x00007ffff7c37609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#10 0x00007ffff7ec6133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Further comments

If this is a relatively large or complex change, kick off the discussion at dev@doris.apache.org by explaining why you chose the solution you did and what alternatives you considered, etc...

@AshinGau
Copy link
Member Author

run buildall

@github-actions
Copy link
Contributor

clang-tidy review says "All clean, LGTM! 👍"

Copy link
Contributor

@yiguolei yiguolei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions github-actions bot added approved Indicates a PR has been approved by one committer. reviewed labels Aug 23, 2023
@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@hello-stephen
Copy link
Contributor

(From new machine)TeamCity pipeline, clickbench performance test result:
the sum of best hot time: 45.63 seconds
stream load tsv: 541 seconds loaded 74807831229 Bytes, about 131 MB/s
stream load json: 20 seconds loaded 2358488459 Bytes, about 112 MB/s
stream load orc: 65 seconds loaded 1101869774 Bytes, about 16 MB/s
stream load parquet: 30 seconds loaded 861443392 Bytes, about 27 MB/s
insert into select: 29.5 seconds inserted 10000000 Rows, about 338K ops/s
storage size: 17161871885 Bytes

Copy link
Contributor

@morningman morningman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@morningman morningman merged commit c6ac925 into apache:master Aug 24, 2023
28 of 30 checks passed
@xiaokang xiaokang mentioned this pull request Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by one committer. dev/2.0.1-merged p0_c reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants