1
0
Fork 0

fix profiler issues

This commit is contained in:
jsteemann 2019-10-23 12:25:05 +02:00
parent 67317e9cb2
commit 787f56f238
3 changed files with 25 additions and 6 deletions

View File

@ -1444,9 +1444,12 @@ ExecutionState Query::cleanupPlanAndEngine(int errorCode, VPackBuilder* statsBui
_engine.reset();
}
// as a side-effect, the following call removes the query from the list of currently
// running queries
_profile.reset();
// the following call removes the query from the list of currently
// running queries. so whoever fetches that list will not see a Query that
// is about to shut down/be destroyed
if (_profile != nullptr) {
_profile->unregisterFromQueryList();
}
// If the transaction was not committed, it is automatically aborted
_trx = nullptr;

View File

@ -44,12 +44,20 @@ QueryProfile::QueryProfile(Query* query)
it = 0.0; // reset timers
}
auto queryList = query->vocbase().queryList();
_tracked = queryList->insert(query);
registerInQueryList(query);
}
/// @brief destroy a profile
QueryProfile::~QueryProfile() {
unregisterFromQueryList();
}
void QueryProfile::registerInQueryList(Query* query) {
auto queryList = query->vocbase().queryList();
_tracked = queryList->insert(query);
}
void QueryProfile::unregisterFromQueryList() noexcept {
// only remove from list when the query was inserted into it...
if (_tracked) {
auto queryList = _query->vocbase().queryList();
@ -58,6 +66,8 @@ QueryProfile::~QueryProfile() {
queryList->remove(_query);
} catch (...) {
}
_tracked = false;
}
}

View File

@ -42,11 +42,14 @@ struct QueryProfile {
QueryProfile(QueryProfile const&) = delete;
QueryProfile& operator=(QueryProfile const&) = delete;
explicit QueryProfile(Query*);
explicit QueryProfile(Query* query);
~QueryProfile();
public:
/// @brief unregister the query from the list of queries, if entered
void unregisterFromQueryList() noexcept;
double setStateDone(QueryExecutionState::ValueType);
/// @brief sets the absolute end time for an execution state
@ -59,6 +62,9 @@ struct QueryProfile {
/// @brief convert the profile to VelocyPack
void toVelocyPack(arangodb::velocypack::Builder&) const;
private:
void registerInQueryList(Query* query);
private:
Query* _query;