8000 enable assertion in QueryContext::collections() (#14448) · RtiWeb/arangodb@d8eeb9e · GitHub
[go: up one dir, main page]

Skip to content

Commit d8eeb9e

Browse files
authored
enable assertion in QueryContext::collections() (arangodb#14448)
1 parent a8b8207 commit d8eeb9e

File tree

5 files changed

+10
-12
lines changed

5 files changed

+10
-12
lines changed

arangod/Aql/Query.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,9 @@ aql::ExecutionState Query::cleanupTrxAndEngines(ErrorCode errorCode) {
14831483
}
14841484
bool usingSystemCollection = false;
14851485
// Ignore queries on System collections, we do not want them to hit failure points
1486-
collections().visit([&usingSystemCollection](std::string const&, Collection& col) -> bool {
1486+
// note that we must call the _const_ version of collections() here, because the non-const
1487+
// version will trigger an assertion failure if the query is already executing!
1488+
const_cast<Query const*>(this)->collections().visit([&usingSystemCollection](std::string const&, Collection const& col) -> bool {
14871489
if (col.getCollection()->system()) {
14881490
usingSystemCollection = true;
14891491
return false;

arangod/Aql/QueryContext.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include "Basics/VelocyPackHelper.h"
3333
#include "Basics/system-functions.h"
3434
#include "Cluster/ServerState.h"
35+
#include "ClusterEngine/ClusterEngine.h"
3536
#include "Graph/Graph.h"
3637
#include "Graph/GraphManager.h"
3738
#include "Logger/LogMacros.h"
@@ -53,7 +54,6 @@ using namespace arangodb::aql;
5354
/// @brief creates a query
5455
QueryContext::QueryContext(TRI_vocbase_t& vocbase, QueryId id)
5556
: _resourceMonitor(GlobalResourceMonitor::instance()),
56-
_baseOverHeadTracker(_resourceMonitor, baseMemoryUsage),
5757
_queryId(id ? id : TRI_NewServerSpecificTick()),
5858
_collections(&vocbase),
5959
_vocbase(vocbase),
@@ -76,9 +76,7 @@ QueryContext::~QueryContext() {
7676
}
7777

7878
Collections& QueryContext::collections() {
79-
#ifndef ARANGODB_USE_GOOGLE_TESTS
80-
TRI_ASSERT(_execState != QueryExecutionState::ValueType::EXECUTION);
81-
#endif
79+
TRI_ASSERT(_execState != QueryExecutionState::ValueType::EXECUTION || ClusterEngine::Mocking);
8280
return _collections;
8381
}
8482

arangod/Aql/QueryContext.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,6 @@ class QueryContext {
146146
/// @brief current resources and limits used by query
147147
arangodb::ResourceMonitor _resourceMonitor;
148148

149-
/// @brief registers/unregisters query base ovehead
150-
arangodb::ResourceUsageScope _baseOverHeadTracker;
151-
152149
TRI_voc_tick_t const _queryId;
153150

154151
/// @brief thread-safe query warnings collector

tests/Mocks/Servers.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,6 @@ std::unique_ptr<arangodb::aql::Query> MockAqlServer::createFakeQuery(
408408
callback(*query);
409409
query->prepareQuery(aql::SerializationFormat::SHADOWROWS);
410410

411-
// auto engine =
412-
// std::make_unique<aql::ExecutionEngine>(*query, aql::SerializationFormat::SHADOWROWS);
413-
// query->setEngine(std::move(engine));
414-
415411
return query;
416412
}
417413

tests/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Basics/Thread.h"
3535
#include "Basics/icu-helper.h"
3636
#include "Cluster/ServerState.h"
37+
#include "ClusterEngine/ClusterEngine.h"
3738
#include "Logger/LogAppender.h"
3839
#include "Logger/Logger.h"
3940
#include "Random/RandomGenerator.h"
@@ -133,6 +134,10 @@ int main(int argc, char* argv[]) {
133134
arangodb::ServerState::instance()->setRebootId(arangodb::RebootId{1});
134135
IcuInitializer::setup(ARGV0);
135136

137+
// enable mocking globally - not awesome, but helps to prevent runtime
138+
// assertions in queries
139+
arangodb::ClusterEngine::Mocking = true;
140+
136141
// Run tests in subthread such that it has a larger stack size in libmusl,
137142
// the stack size for subthreads has been reconfigured in the
138143
// ArangoGlobalContext above in the libmusl case:

0 commit comments

Comments
 (0)
0