Fix transaction pk violation (#22057)

* Handle PK violation issue for transaction notification. The transaction might be replayed due to
validator restart.
This commit is contained in:
Lijun Wang 2021-12-22 00:58:51 -08:00 committed by GitHub
parent bf8fbf8383
commit d6de4a2f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -492,7 +492,15 @@ impl SimplePostgresClient {
) -> Result<Statement, AccountsDbPluginError> {
let stmt = "INSERT INTO transaction AS txn (signature, is_vote, slot, message_type, legacy_message, \
v0_loaded_message, signatures, message_hash, meta, updated_on) \
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)";
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) \
ON CONFLICT (slot, signature) DO UPDATE SET is_vote=excluded.is_vote, \
message_type=excluded.message_type, \
legacy_message=excluded.legacy_message, \
v0_loaded_message=excluded.v0_loaded_message, \
signatures=excluded.signatures, \
message_hash=excluded.message_hash, \
meta=excluded.meta, \
updated_on=excluded.updated_on";
let stmt = client.prepare(stmt);