diff --git a/storage/postgreskv/client.go b/storage/postgreskv/client.go index 77c188f9b..efab743f0 100644 --- a/storage/postgreskv/client.go +++ b/storage/postgreskv/client.go @@ -6,6 +6,7 @@ package postgreskv import ( "context" "database/sql" + "sort" "github.com/lib/pq" "github.com/spacemonkeygo/monkit/v3" @@ -164,6 +165,11 @@ func (client *Client) Delete(ctx context.Context, key storage.Key) (err error) { func (client *Client) DeleteMultiple(ctx context.Context, keys []storage.Key) (_ storage.Items, err error) { defer mon.Task()(&ctx, len(keys))(&err) + // make sure deletes always happen in the same order + sort.Slice(keys, func(i, j int) bool { + return keys[i].Less(keys[j]) + }) + rows, err := client.db.QueryContext(ctx, ` DELETE FROM pathdata WHERE fullpath = any($1::BYTEA[])