Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
Prevent potential deadlock
Browse files Browse the repository at this point in the history
Prevent a potential deadlock on the chunk's series_id, time unique
index.
  • Loading branch information
cevian committed Oct 6, 2020
1 parent 3cc8e82 commit b241874
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/pgmodel/sql_ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func doInsert(conn pgxConn, req copyRequest) (err error) {
if len(times) != numRows {
panic("invalid insert request")
}
queryString := fmt.Sprintf("INSERT INTO %s(time, value, series_id) SELECT * FROM unnest($1::TIMESTAMPTZ[], $2::DOUBLE PRECISION[], $3::BIGINT[]) a ON CONFLICT DO NOTHING", pgx.Identifier{dataSchema, req.table}.Sanitize())
queryString := fmt.Sprintf("INSERT INTO %s(time, value, series_id) SELECT * FROM unnest($1::TIMESTAMPTZ[], $2::DOUBLE PRECISION[], $3::BIGINT[]) a(t,v,s) ORDER BY s,t ON CONFLICT DO NOTHING", pgx.Identifier{dataSchema, req.table}.Sanitize())
var ct pgconn.CommandTag
ct, err = conn.Exec(context.Background(), queryString, times, vals, series)
if err != nil {
Expand Down

0 comments on commit b241874

Please sign in to comment.