Skip to content

Commit 63acbae

Browse files
authored
copyTrees: add timeouts and order to sync function (#98)
1 parent 6af5137 commit 63acbae

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

cmd/api/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ func check(err error) {
3535
}
3636

3737
func copyTrees(ctx context.Context, db *pgxpool.Pool) {
38+
ctx, done := context.WithTimeout(ctx, 5*time.Minute)
39+
defer done()
3840
t, err := db.Exec(ctx, `
3941
insert into trees_proofs
4042
(select root, proofs from trees
4143
where root not in (select root from trees_proofs)
44+
order by inserted_at desc
4245
limit 5
4346
for update skip locked)
4447
`)

0 commit comments

Comments
 (0)