Skip to content

Commit

Permalink
fix: reduce deadlock potential (NUWCDIVNPT#216)
Browse files Browse the repository at this point in the history
  • Loading branch information
csmig committed Mar 30, 2021
1 parent 3632841 commit 698418d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/source/service/mysql/AssetService.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ exports.queryAssets = async function (inProjection = [], inPredicates = {}, elev

// PROJECTIONS
if (inProjection.includes('adminStats')) {
let statsJoin = 'stats_asset_stig sas WHERE sas.assetId = a.assetId'
let statsJoin = 'stig_asset_map sam inner join stats_asset_stig sas on (sam.assetId=sas.assetId and sam.benchmarkId=sas.benchmarkId) WHERE sas.assetId = a.assetId'
columns.push(`json_object(
'stigCount', COUNT(distinct sa.saId),
'stigAssignedCount', COUNT(distinct usa.saId),
Expand Down
3 changes: 2 additions & 1 deletion api/source/service/mysql/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ module.exports.updateStatsAssetStig = async function(connection, { collectionId,
group by
sa.assetId,
sa.benchmarkId
FOR UPDATE
`

const sqlUpsert = `
Expand Down Expand Up @@ -392,7 +393,7 @@ module.exports.updateStatsAssetStig = async function(connection, { collectionId,
let bindsUpsert = results.map( r => Object.values(r))
let stats;
[stats] = await connection.query(sqlUpsert, [bindsUpsert])
await connection.query(sqlIntegrity)
// await connection.query(sqlIntegrity)
return stats
}
else {
Expand Down

0 comments on commit 698418d

Please sign in to comment.