diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e2dd2afb9..de60d4a97b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ ### 🐛 Fixes - [11672](https://github.com/vegaprotocol/vega/issues/11672) - Add missing fees in GraphQL bindings. +- [11681](https://github.com/vegaprotocol/vega/issues/11681) - Account for conflicts inserting funding payment records. ## 0.78.2 diff --git a/datanode/sqlstore/funding_payments.go b/datanode/sqlstore/funding_payments.go index 270f8df75b..85dfc78f15 100644 --- a/datanode/sqlstore/funding_payments.go +++ b/datanode/sqlstore/funding_payments.go @@ -52,7 +52,12 @@ func (fp *FundingPayments) Add( for _, v := range fundingPayments { _, err := fp.Exec(ctx, `insert into funding_payment(market_id, party_id, funding_period_seq, amount, vega_time, tx_hash, loss_socialisation_amount) -values ($1, $2, $3, $4, $5, $6, $7)`, +values ($1, $2, $3, $4, $5, $6, $7) + ON CONFLICT (party_id, market_id, vega_time) DO UPDATE SET + funding_period_seq=EXCLUDED.funding_period_seq, + amount=EXCLUDED.amount, + tx_hash=EXCLUDED.tx_hash, + loss_socialisation_amount=EXCLUDED.loss_socialisation_amount`, v.MarketID, v.PartyID, v.FundingPeriodSeq, v.Amount, v.VegaTime, v.TxHash, v.LossSocialisationAmount) if err != nil { return err