Fix concurrent query module race condition (#1158)

Concurrent access to the same query module had a race condition on the
pointer that was used to handle the custom memory management. With this
commit, a mapping has been added to keep information about what
thread used the pointer to handle the memory resources. This should be
fine since the respected query executions are running on a dedicated
thread. Access to the mapping itself is threadsafe. A simple RAII
wrapper for the mapping container has also been added for simpler
client-side use.
This commit is contained in:
gvolfing
2023-08-21 16:45:36 +02:00
committed by GitHub
parent 97183fb9da
commit 476968e2c8
11 changed files with 427 additions and 159 deletions

View File

@@ -27,12 +27,13 @@
template <typename StorageType>
struct CppApiTestFixture : public ::testing::Test {
protected:
virtual void SetUp() override { mgp::memory = &memory; }
virtual void SetUp() override { mgp::mrd.Register(&memory); }
void TearDown() override {
if (std::is_same<StorageType, memgraph::storage::DiskStorage>::value) {
disk_test_utils::RemoveRocksDbDirs(testSuite);
}
mgp::mrd.UnRegister();
}
mgp_graph CreateGraph(const memgraph::storage::View view = memgraph::storage::View::NEW) {