Skip to content

Commit

Permalink
use table locks to prevent stale reads from trigger (MRXN23-572)
Browse files Browse the repository at this point in the history
  • Loading branch information
hotzevzl committed Jan 31, 2024
1 parent 5bf5056 commit c7c1eb0
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ export class ScenarioMetadataPieceImporter implements ImportPieceProcessor {
if (scenarioCloning) {
await this.updateScenario(em, scenarioId, metadata, input.ownerId);
} else {
/**
* Aggressive locking on the table is used here in order to ensure that by the time
* the trigger function that is executed on insert will not get stale data from
* concurrent transactions. Inserting in serializable mode seems not to be enough,
* from checks done when this lock was added.
*/
await em.query('lock table scenarios');
await this.createScenario(
em,
scenarioId,
Expand Down

0 comments on commit c7c1eb0

Please sign in to comment.