fix: fix and improve primary keys on projections (#3708)

* fix: org_domain projection

* fix: projection reset

* fix test

* improve foreign keys on suffixed tables
This commit is contained in:
Livio Amstutz
2022-05-25 14:15:13 +02:00
committed by GitHub
parent 79452da7d6
commit 737e01bfd2
20 changed files with 403 additions and 156 deletions

View File

@@ -15,10 +15,9 @@ import (
)
const (
lockStmtFormat = "INSERT INTO %[1]s" +
" (locker_id, locked_until, projection_name) VALUES ($1, now()+$2::INTERVAL, $3)" +
" ON CONFLICT (projection_name)" +
" DO UPDATE SET locker_id = $1, locked_until = now()+$2::INTERVAL"
lockStmtFormat = "UPDATE %[1]s" +
" set locker_id = $1, locked_until = now()+$2::INTERVAL" +
" WHERE projection_name = $3"
lockerIDReset = "reset"
)
@@ -136,7 +135,7 @@ func (q *Queries) checkAndLock(ctx context.Context, projectionName string) error
if err != nil || rows == 0 {
return errors.ThrowInternal(err, "QUERY-Bh3ws", "Errors.RemoveFailed")
}
time.Sleep(7 * time.Second) //more than twice the default lock duration (10s)
time.Sleep(7 * time.Second) //more than half the default lock duration (10s)
return nil
}