Skip to content

Commit

Permalink
Nicer logs for AQL profiling
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Aug 14, 2021
1 parent 2fd56c0 commit 2991428
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions oada/libs/oada-lib-arangodb/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,23 @@ class DatabaseWrapper extends Database {
override async query(query: AqlQuery, options: QueryOptions = {}) {
let tries = 0;
const tryquery: () => ReturnType<Database['query']> = async () => {
return await Bluebird.resolve(super.query(query, {profile, ...options})).catch(
DeadlockError,
async (err: unknown) => {
if (++tries >= deadlockRetries) {
throw err;
}
return await Bluebird.resolve(super.query(query, { profile, ...options }))
.catch(
DeadlockError,
async (err: unknown) => {
if (++tries >= deadlockRetries) {
throw err;
}

// warn(`Retrying query due to deadlock (retry #${tries})`, err);
return await Bluebird.delay(deadlockDelay).then(tryquery);
}
);
// warn(`Retrying query due to deadlock (retry #${tries})`, err);
return await Bluebird.delay(deadlockDelay).then(tryquery);
});
}
const res = await tryquery();
// TODO: Less gross way to do this?
if (trace.enabled) {
trace({...query, ...res.extra}, 'AQL query info')
const { query: aql, ...rest } = query;
trace({ ...rest, ...res.extra }, aql);
}
return res
}
Expand Down

0 comments on commit 2991428

Please sign in to comment.