Skip to content

Fix query counter gauge #21785

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

Open
wants to merge 8 commits into
base: devel
Choose a base branch
from
Open

Fix query counter gauge #21785

wants to merge 8 commits into from

Conversation

jbajic
Copy link
Contributor

@jbajic jbajic commented May 26, 2025

Scope & Purpose

The arangodb_aql_current_query metrics could underflow when going below 0 and show the number of queries currently executing. This fixes the issue

  • 💩 Bugfix
  • 🍕 New feature
  • 🔥 Performance improvement
  • 🔨 Refactoring/simplification

Checklist

  • Tests
    • Regression tests
    • C++ Unit tests
    • integration tests
    • resilience tests
  • 📖 CHANGELOG entry made
  • 📚 documentation written (release notes, API changes, ...)
  • Backports
    • Backport for 3.12.0: (Please link PR)
    • Backport for 3.11: (Please link PR)
    • Backport for 3.10: (Please link PR)

Related Information

(Please reference tickets / specification / other PRs etc)

@cla-bot cla-bot bot added the cla-signed label May 26, 2025
@jbajic jbajic marked this pull request as ready for review May 26, 2025 11:40
Comment on lines 695 to 698
auto& queryRegistryFeature =
vocbase().server().getFeature<QueryRegistryFeature>();
queryRegistryFeature.trackQueryStart();
_isExecuting = true;
Copy link
Member

Choose a reason for hiding this comment

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

I think moving it out of instantiatePlan() is a good idea. More than that, I think it was actually incorrect before and only called in certain situations. But here is not the right place to call it, either:

The name of the function (execute()) is somewhat misleading: it contains everything from parsing, optimization, instantiation, execution and cleanup. The execution part happens below in case ExecutionPhase::EXECUTE:. But note that this function is also reentrant due to the WAITING mechanism, so it will be called multiple times (possibly a lot) during the execution of a query.

Also, there's executeV8(), which is basically a re-implementation called from V8 contexts (e.g. Foxx microservices); so anything you add to execute(), you probably need to do there as well.

I think we either need to look at where enterState(QueryExecutionState::ValueType::EXECUTION) is called, or when _executionPhase = ExecutionPhase::EXECUTE is set. These should (I think) be mostly the same, looking from the outside.

@goedderz
Copy link
Member

@jbajic I think this should also get a simple regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[3.12.4] arangodb_aql_current_query shows invalid uint64 value (overflow?) on SINGLE setup
2 participants