[pull] master from memgraph:master#23
Merged
pull[bot] merged 2 commits intoweslien:masterfrom Apr 11, 2025
Merged
Conversation
The PR tries to clean .old directories inside databases/ folder also to handle the case when test is run with MT configuration.
Add functionality for composite index on vertices. Extending label + property index to have multiple properties. `CREATE INDEX ON :L(a,b,c);`. The ordering of the properties matter, `:L(a,b)` is different from `:L(b,a)`. The index is used in planning to reduce the cost of scan + filter, by using the lowest costing index to improve performance of the scan. breaking: SHOW INDEX INFO; will now have a list for label+properties index --------- Co-authored-by: Colin Barry <colin.barry@memgraph.io>
pull bot
pushed a commit
that referenced
this pull request
Mar 4, 2026
Solves TSAN warning in the shutdown handler.
```
WARNING: ThreadSanitizer: signal-unsafe call inside of a signal (pid=522648) 10:17:33
[1923/1992]
#0 operator new(unsigned long) /memgraph/environment/toolchain/v7/build/llvmorg-20.1.7/compiler-rt/lib/tsan/rtl/tsan_new_delete.cpp:64:3 (memgraph+0x12ce4fc) (BuildId:
6eb00db3
a6a8a3fc6c8a2418d89f921a45cd3ca1)
#1 std::__new_allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<void>,
(__gnu_cxx::_Lock_pol
icy)2>>::allocate(unsigned long, void const*) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/new_allocator.h:151:27
(memgraph+0x13513
80) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#2 std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<void>,
(__gnu_cxx::_Lock_policy)2>
>::allocate(unsigned long) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/allocator.h:203:32 (memgraph+0x1351380)
#3 std::allocator_traits<std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>,
std::allocator<void>, (__gn
u_cxx::_Lock_policy)2>>>::allocate(std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>,
std::allocator<void>,
(__gnu_cxx::_Lock_policy)2>>&, unsigned long) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/alloc_traits.h:614:20
(memgraph+0x13513
80)
#4 std::__allocated_ptr<std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<void>,
(__gnu
_cxx::_Lock_policy)2>>> std::__allocate_guarded<std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>,
std::all
ocator<void>, (__gnu_cxx::_Lock_policy)2>>>(std::allocator<std::_Sp_counted_ptr_inplace<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>,
std::allocat
or<void>, (__gnu_cxx::_Lock_policy)2>>&) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/allocated_ptr.h:102:21
(memgraph+0x1351380)
#5 std::__shared_count<(__gnu_cxx::_Lock_policy)2>::__shared_count<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<void>,
char*,
unsigned long>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*&, std::_Sp_alloc_shared_tag<std::allocator<void>>, char*&&, unsigned long&&)
/opt/too
lchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/shared_ptr_base.h:967:19 (memgraph+0x1351380)
#6 std::__shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, (__gnu_cxx::_Lock_policy)2>::__shared_ptr<std::allocator<void>,
char*, unsi
gned long>(std::_Sp_alloc_shared_tag<std::allocator<void>>, char*&&, unsigned long&&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/
shared_ptr_base.h:1719:14 (memgraph+0x134fef8) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#7 std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>::shared_ptr<std::allocator<void>, char*, unsigned
long>(std::_Sp_alloc_shared
_tag<std::allocator<void>>, char*&&, unsigned long&&) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/shared_ptr.h:463:4
(memgraph+0x1
34fef8)
#8 std::shared_ptr<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>> std::make_shared<std::__cxx11::basic_string<char,
std::char_traits<char>, std
::allocator<char>>, char*, unsigned long>(char*&&, unsigned long&&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/shared_ptr.h:1007:
14 (memgraph+0x134fef8)
#9 memgraph::communication::websocket::Server::LoggingSink::sink_it_(spdlog::details::log_msg const&)
/home/andi.linux/Memgraph/code/memgraph/src/communication/websocket/server
.cpp:86:24 (memgraph+0x134fef8)
#10 spdlog::sinks::base_sink<std::mutex>::log(spdlog::details::log_msg const&)
/home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/b/src/include/spdlog/sinks/base_sink-inl.h:28:5 (
memgraph+0x47e78dc) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#11 spdlog::sinks::dist_sink<std::mutex>::sink_it_(spdlog::details::log_msg const&)
/home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/p/include/spdlog/sinks/dist_sink.h:53:27 (me
mgraph+0x1987c80) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#12 spdlog::sinks::base_sink<std::mutex>::log(spdlog::details::log_msg const&)
/home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/b/src/include/spdlog/sinks/base_sink-inl.h:28:5 (
memgraph+0x47e78dc) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#13 spdlog::logger::sink_it_(spdlog::details::log_msg const&) /home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/b/src/include/spdlog/logger-inl.h:138:32
(memgraph+0x47de8c8) (Bui
ldId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#14 spdlog::logger::log_it_(spdlog::details::log_msg const&, bool, bool) /home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/b/src/include/spdlog/logger-inl.h:128:9
(memgraph+0x47d
e7bc) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#15 spdlog::logger::log(spdlog::source_loc, spdlog::level::level_enum, fmt::v11::basic_string_view<char>)
/home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/p/include/spdlog/logge
r.h:123:9 (memgraph+0x12da05c) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#16 void spdlog::logger::log<char [23]>(spdlog::level::level_enum, char const (&) [23]) /home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/p/include/spdlog/logger.h:90:9
(memgraph
+0x12da05c)
#17 void spdlog::logger::trace<char [23]>(char const (&) [23]) /home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/p/include/spdlog/logger.h:233:9 (memgraph+0x12da05c)
#18 void spdlog::trace<char [23]>(char const (&) [23]) /home/andi.linux/.conan2/p/b/spdlo51f82ed51ef4e/p/include/spdlog/spdlog.h:248:27 (memgraph+0x12da05c)
#19 main::$_7::operator()() const /home/andi.linux/Memgraph/code/memgraph/src/memgraph.cpp:861:5 (memgraph+0x12da05c)
#20 void std::__invoke_impl<void, main::$_7&>(std::__invoke_other, main::$_7&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/inv
oke.h:63:14 (memgraph+0x12da05c)∫ #21 std::enable_if<is_invocable_r_v<void, main::$_7&>, void>::type std::__invoke_r<void, main::$_7&>(main::$_7&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../..
/../../include/c++/15.1.0/bits/invoke.h:113:2 (memgraph+0x12da05c)
#22 std::_Function_handler<void (), main::$_7>::_M_invoke(std::_Any_data const&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/s
td_function.h:292:9 (memgraph+0x12da05c)
#23 std::function<void ()>::operator()() const /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/std_function.h:10:31:48 [256/347]
(memgraph+0x12
d9804) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#24 (anonymous namespace)::InitSignalHandlers(std::function<void ()> const&)::$_0::operator()() const /home/andi.linux/Memgraph/code/memgraph/src/memgraph.cpp:162:5
(memgraph+0
x12d9804)
#25 void std::__invoke_impl<void, (anonymous namespace)::InitSignalHandlers(std::function<void ()> const&)::$_0&>(std::__invoke_other, (anonymous
namespace)::InitSignalHandlers
(std::function<void ()> const&)::$_0&) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/invoke.h:63:14 (memgraph+0x12d9804)
#26 std::enable_if<is_invocable_r_v<void, (anonymous namespace)::InitSignalHandlers(std::function<void ()> const&)::$_0&>, void>::type std::__invoke_r<void, (anonymous
namespac
e)::InitSignalHandlers(std::function<void ()> const&)::$_0&>((anonymous namespace)::InitSignalHandlers(std::function<void ()> const&)::$_0&)
/opt/toolchain-v7/bin/../lib/gcc/aarch6
4-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/invoke.h:113:2 (memgraph+0x12d9804)
#27 std::_Function_handler<void (), (anonymous namespace)::InitSignalHandlers(std::function<void ()> const&)::$_0>::_M_invoke(std::_Any_data const&)
/opt/toolchain-v7/bin/../li
b/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/std_function.h:292:9 (memgraph+0x12d9804)
#28 std::function<void ()>::operator()() const /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/std_function.h:593:9
(memgraph+0x15
b1efc) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#29 memgraph::utils::SignalHandler::Handle(int) /home/andi.linux/Memgraph/code/memgraph/src/utils/signals.cpp:31:42 (memgraph+0x15b1efc)
#30 __tsan::CallUserSignalHandler(__tsan::ThreadState*, bool, bool, int, __sanitizer::__sanitizer_siginfo*, void*)
/memgraph/environment/toolchain/v7/build/llvmorg-20.1.7/compi
ler-rt/lib/tsan/rtl/tsan_interceptors_posix.cpp:2145:43 (memgraph+0x1211b34) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#31 __gthread_join(unsigned long, void**)
/memgraph/environment/toolchain/v7/build/gcc-15.1.0/build/aarch64-linux-gnu/libstdc++-v3/include/aarch64-linux-gnu/bits/gthr-default.h
:715:33 (libstdc++.so.6+0xe5ddc) (BuildId: 39a8b04cda92f00933ba21b588532091b99da155)
#32 std::thread::join()
/memgraph/environment/toolchain/v7/build/gcc-15.1.0/build/aarch64-linux-gnu/libstdc++-v3/src/c++11/../../../../../libstdc++-v3/src/c++11/thread.cc:134:2
7 (libstdc++.so.6+0xe5ddc)
#33 void std::destroy_at<std::jthread>(std::jthread*) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/stl_construct.h:88:15
(memgr
aph+0x1600248) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1)
#34 void std::_Destroy<std::jthread>(std::jthread*) /opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/stl_construct.h:164:7
(memgrap
h+0x1600248)
#35 void std::_Destroy<std::jthread*>(std::jthread*, std::jthread*)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/stl_construct.
h:212:4 (memgraph+0x1600248)
#36 void std::_Destroy<std::jthread*, std::jthread>(std::jthread*, std::jthread*, std::allocator<std::jthread>&)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../..
/../../include/c++/15.1.0/bits/alloc_traits.h:1045:7 (memgraph+0x1600248)
#37 std::vector<std::jthread, std::allocator<std::jthread>>::_M_erase_at_end(std::jthread*)
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15
.1.0/bits/stl_vector.h:2237:6 (memgraph+0x1600248)
#38 std::vector<std::jthread, std::allocator<std::jthread>>::clear()
/opt/toolchain-v7/bin/../lib/gcc/aarch64-linux-gnu/15.1.0/../../../../include/c++/15.1.0/bits/stl_vector.h:
1864:9 (memgraph+0x1600248)
#39 memgraph::utils::PriorityThreadPool::AwaitShutdown() /home/andi.linux/Memgraph/code/memgraph/src/utils/priority_thread_pool.cpp:164:50 (memgraph+0x1600248)
#40 main /home/andi.linux/Memgraph/code/memgraph/src/memgraph.cpp:926:35 (memgraph+0x12d607c) (BuildId: 6eb00db3a6a8a3fc6c8a2418d89f921a45cd3ca1) SUMMARY:
ThreadSanitizer: signal-unsafe call inside of a signal /home/andi.linux/Memgraph/code/memgraph/src/communication/websocket/server.cpp:86:24 in memgraph::communication::web
socket::Server::LoggingSink::sink_it_(spdlog::details::log_msg const&)
```
## What
Replace the async signal handler for SIGTERM/SIGINT with a synchronous
`sigwait()`-based approach. The shutdown function now runs on the main
thread in normal context instead of
inside a signal handler.
## Why
The previous implementation registered SIGTERM/SIGINT handlers via
`sigaction` that directly invoked the shutdown lambda. That lambda
performs logging
(`spdlog::trace`/`spdlog::info`), heap allocation
(`std::make_shared<std::string>` inside `LoggingSink::sink_it_`), and
mutex acquisition — none of which are async-signal-safe.
ThreadSanitizer reports this as `signal-unsafe call inside of a signal`,
and it can cause deadlocks or undefined behaviour if the signal
interrupts a thread holding the allocator
or spdlog lock.
## How
- **`BlockShutdownSignals()`** uses `pthread_sigmask(SIG_BLOCK)` to
block SIGTERM and SIGINT. Called before starting servers so all spawned
threads inherit the blocked mask and
never run an async handler for these signals.
- **`WaitForShutdownSignal()`** calls `sigwait()` on the main thread,
which blocks until one of the masked signals becomes pending. When it
returns, the shutdown function
executes in normal thread context — no signal-safety constraints apply.
- The old `InitSignalHandlers()`, `is_shutting_down` flag, and
`SignalHandler::RegisterHandler` calls for SIGTERM/SIGINT are removed.
Double-shutdown prevention is inherent:
`sigwait` consumes the signal exactly once, and subsequent signals
remain blocked/pending.
- The main thread flow changes from `start servers → AwaitShutdown
(blocks, signal handler does shutdown)` to `start servers → sigwait
(blocks) → run shutdown → AwaitShutdown
(joins already-stopped threads)`.
## Testing
No new automated tests added. The fix is verified by running memgraph
under TSAN and sending `kill -TERM`:
- Before: `WARNING: ThreadSanitizer: signal-unsafe call inside of a
signal` at `LoggingSink::sink_it_`
- After: clean shutdown with `Received signal 15, shutting down...` and
no TSAN warning
Existing HA e2e tests under TSAN cover the shutdown path and should no
longer produce this warning.
## Notes for reviewers
- The SIGUSR2 handler for audit log rotation (`audit_log.ReopenLog()`)
has the same signal-safety issue (mutex + file I/O inside a handler) but
is left unchanged — it's a
separate concern and lower risk since SIGUSR2 is only sent by logrotate.
- The `.gitignore` change (adding `CLAUDE.md`) is unrelated
housekeeping.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.1)
Can you help keep this open source service alive? 💖 Please sponsor : )