Hi,
We have been trying to resolve this issue by reducing the number of database calls required for this transaction, and using select for update, now we have 2 calls and would like to reduce it to a single big SQL block.
The root of the problem is that numerous db clients are attempting to update the same rows at the same time to increment a counter column. However, we understood that using select for update should order the transactions. We also do calls to kafka after starting the transaction which add latency.
Any help much appreciated.
John
Exception message : 40001: restart transaction: TransactionRetryWithProtoRefreshError: TransactionAbortedError(ABORT_REASON_ABORT_SPAN): "sql txn" meta={id=b4bfd98e key=/Table/98/5/624582547018547201 pri=0.00550365 epo=0 ts=1610861196.560901215,1 min=1610861193.890266262,0 seq=12} lock=true stat=ABORTED rts=1610861194.963549468,2 wto=false max=1610861193.890266262,0
StackTrace : at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Npgsql.NpgsqlConnector.<>c__DisplayClass160_0.<<DoReadMessage>g__ReadMessageLong|0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at Npgsql.NpgsqlConnector.ExecuteInternalCommand(Byte[] data, Boolean async)
at Npgsql.NpgsqlTransaction.Commit(Boolean async)
at Npgsql.NpgsqlTransaction.Commit()