8000 Move async task cleanup before transaction destruction by jbajic · Pull Request #21734 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Move async task cleanup before transaction destruction #21734

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

Merged
merged 10 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix assertion
  • Loading branch information
jbajic committed Jun 2, 2025
commit cb762f17a444e199eb2d267d06497d5ce258cf4b
2 changes: 1 addition & 1 deletion arangod/Aql/ExecutionBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,5 +212,5 @@ auto ExecutionBlock::printBlockInfo() const -> std::string const {
auto ExecutionBlock::stopAsyncTasks() -> void {}

#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
auto ExecutionBlock::isPrefetchTaskDone() noexcept -> bool { return false; }
auto ExecutionBlock::isPrefetchTaskActive() noexcept -> bool { return false; }
#endif
2 changes: 1 addition & 1 deletion arangod/Aql/ExecutionBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ class ExecutionBlock {

virtual auto stopAsyncTasks() -> void;

virtual auto isPrefetchTaskDone() noexcept -> bool;
virtual auto isPrefetchTaskActive() noexcept -> bool;

protected:
// Trace the start of a execute call
Expand Down
3 changes: 2 additions & 1 deletion arangod/Aql/ExecutionBlockImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ class ExecutionBlockImpl final : public ExecutionBlock {
void stopAsyncTasks() override;

#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
bool isPrefetchTaskDone() noexcept override;
bool isPrefetchTaskActive() noexcept override;
#endif

private:
Expand Down Expand Up @@ -387,6 +387,7 @@ class ExecutionBlockImpl final : public ExecutionBlock {
: _block(block), _stack(stack) {}

bool isConsumed() const noexcept;
bool isFinished() const noexcept;
bool tryClaim() noexcept;
bool tryClaimOrAbandon() noexcept;
void waitFor() const noexcept;
Expand Down
10 changes: 8 additions & 2 deletions arangod/Aql/ExecutionBlockImpl.tpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,8 +386,9 @@ void ExecutionBlockImpl<Executor>::stopAsyncTasks() {

#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
template<class Executor>
bool ExecutionBlockImpl<Executor>::isPrefetchTaskDone() noexcept {
return _prefetchTask == nullptr || _prefetchTask->isConsumed();
bool ExecutionBlockImpl<Executor>::isPrefetchTaskActive() noexcept {
return _prefetchTask != nullptr &&
(!_prefetchTask->isConsumed() || !_prefetchTask->isFinished());
}
#endif

Expand Down Expand Up @@ -2570,6 +2571,11 @@ bool ExecutionBlockImpl<Executor>::PrefetchTask::isConsumed() const noexcept {
return _state.load(std::memory_order_relaxed).status == Status::Consumed;
}

template<class Executor>
bool ExecutionBlockImpl<Executor>::PrefetchTask::isFinished() const noexcept {
return _state.load(std::memory_order_relaxed).status == Status::Finished;
}

template<class Executor>
bool ExecutionBlockImpl<Executor>::PrefetchTask::tryClaim() noexcept {
auto state = _state.load(std::memory_order_relaxed);
Expand Down
9 changes: 5 additions & 4 deletions arangod/Aql/ExecutionEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,11 @@ ExecutionEngine::~ExecutionEngine() {
std::this_thread::sleep_for(10ms);
}

TRI_ASSERT(std::count_if(
_blocks.begin(), _blocks.end(),
[](const auto& block) { return !block->isPrefetchTaskDone(); }))
<< "Some prefetch tasks were not destroyed before";
TRI_ASSERT(std::count_if(_blocks.begin(), _blocks.end(),
[](const auto& block) {
return block->isPrefetchTaskActive();
}) == 0)
<< "Some async prefetch tasks were not destroyed before";
stopAsyncTasks();

if (_sharedState) { // ensure no async task is working anymore
Expand Down
0