Cardano-db-sync duplicate key

hi

cardano-db-sync is running into “duplicate key issue”. Has someone a SQL statement to cleanup the last block or epoch? Or do i really have to restore from snapshot because of this?

ErrorPolicyUnhandledApplication
Exception (DbInsertException "Tx: 32" (SqlError {sqlState = "23505", sqlExecStatus = FatalError, sqlErrorMsg = "duplicate key value violates unique constraint \"unique_tx\"", sqlErrorDetail = "Key (hash)=(\\xc9c4b761076691ea28c64f09acc87985fb3b404bc0861207c73910c12bb51bf7) already exists.", sqlErrorHint = ""}))

solved it as follows

1/ find block_id of transaction violating key constraint:

select block_id from tx where hash='\xc9c4b761076691ea28c64f09acc87985fb3b404bc0861207c73910c12bb51bf7';

2/ checked how many transactions are in the block for verification later

select * from tx where block_id = 8284403;

3/ deleted all transactions for block

delete from tx where block_id = 8284403;

restarted cardano-db-sync and searched for hash again. it get’s a different block_id now but seems consistent as all transactions are there. It’s faster than restore…

How do we know that’s a valid solution to the problem? I would not consider that as a safe or approved method unless we get a definitive answer. Is there anyone from the Development team that can weigh in on this?