Skip to content

Commit

Permalink
perf: avoid to wait for tables if is not necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
limcross committed Nov 9, 2022
1 parent 764d3b3 commit 4e201e4
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/_update_replication.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ module.exports = async (arc, stage, dryRun) => {
ReplicaUpdates: [ replicateUpdate ]
}).promise()

do { // Wait to avoid errors with busy tables
await new Promise(r => setTimeout(r, 5000));
({ Table } = await dynamoPrimary.describeTable({ TableName: PhysicalTableName }).promise())
} while (
!Table.Replicas ||
Table.Replicas.findIndex((replica) => [ 'CREATING', 'UPDATING', 'DELETING' ].includes(replica.ReplicaStatus)) >= 0
)
if (replicateUpdates.length > 1) {
do { // Wait to avoid errors with busy table
await new Promise(r => setTimeout(r, 5000));
({ Table } = await dynamoPrimary.describeTable({ TableName: PhysicalTableName }).promise())
} while (
!Table.Replicas ||
Table.Replicas.findIndex((replica) => [ 'CREATING', 'UPDATING', 'DELETING' ].includes(replica.ReplicaStatus)) >= 0
)
}
}
}
catch (error) {
Expand Down

0 comments on commit 4e201e4

Please sign in to comment.