Skip to content

Commit

Permalink
Merge pull request awaragi#1 from wfelipew/patch-1
Browse files Browse the repository at this point in the history
Fix race condition between different databases
  • Loading branch information
CaeirOps authored Jun 15, 2020
2 parents 5be5435 + a5f0f0a commit 95f62e5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ async function queryStoreCollect(connection) {
}
}

async function syncExecSQL(dbrequest) {
return new Promise((resolve) => {
connection.execSql(dbrequest);

});
}

async function collectQueryStoreDB(connection) {
return new Promise((resolve) => {
let request = new Request("SELECT name FROM sys.databases WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb')", async function (error, rowCount, rows) {
Expand All @@ -112,10 +119,13 @@ async function collectQueryStoreDB(connection) {
if (!DBerror && DBrowCount > 0 && DBrows[0][0].value != "OFF") {
await queryStoreCollect(dbconnect);
}

delete config.connect.options.database;
dbconnect.close();
resolve();
});
dbconnect.execSql(dbrequest);

await syncExecSQL(dbrequest);
}
resolve();
} else {
Expand Down

0 comments on commit 95f62e5

Please sign in to comment.