MM-38419: Split UPSERT statement into 2 (#19536)
The UPSERT statement was taking unexplained gap locks, due to which the import was somehow failing. I still don't know exactly how this is happening. But splitting the UPSERT into 2 different statements in the same transaction changes the locking semantics, and avoids the deadlock. Naturally, this proves that even our retrylayer is sometimes ineffective against some problems. ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
01a3ed0d3e
Коммит
446306a274
@@ -540,14 +540,17 @@ func (s SqlChannelStore) upsertPublicChannelT(transaction *sqlxTxWrapper, channe
|
|||||||
PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
|
PublicChannels(Id, DeleteAt, TeamId, DisplayName, Name, Header, Purpose)
|
||||||
VALUES
|
VALUES
|
||||||
(:id, :deleteat, :teamid, :displayname, :name, :header, :purpose)
|
(:id, :deleteat, :teamid, :displayname, :name, :header, :purpose)
|
||||||
ON DUPLICATE KEY UPDATE
|
`, vals)
|
||||||
DeleteAt = :deleteat,
|
if err != nil && IsUniqueConstraintError(err, []string{"PRIMARY"}) {
|
||||||
|
_, err = transaction.NamedExec(`UPDATE PublicChannels
|
||||||
|
SET deleteAt = :deleteat,
|
||||||
TeamId = :teamid,
|
TeamId = :teamid,
|
||||||
DisplayName = :displayname,
|
DisplayName = :displayname,
|
||||||
Name = :name,
|
Name = :name,
|
||||||
Header = :header,
|
Header = :header,
|
||||||
Purpose = :purpose;
|
Purpose = :purpose
|
||||||
`, vals)
|
WHERE Id=:id`, vals)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
_, err = transaction.NamedExec(`
|
_, err = transaction.NamedExec(`
|
||||||
INSERT INTO
|
INSERT INTO
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user