diff OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5464:38f1d06875ad pg-transactions

delete attachment in case of same instance being uploaded multiple times at the same time
author Alain Mazy <am@osimis.io>
date Tue, 12 Dec 2023 17:20:10 +0100
parents 06eb8bc9f024
children dceed5e3d6a9
line wrap: on
line diff
--- a/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Fri Dec 08 10:27:24 2023 +0100
+++ b/OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp	Tue Dec 12 17:20:10 2023 +0100
@@ -3157,7 +3157,9 @@
               // in very rare occasions in READ COMMITTED mode when multiple clients are pushing the same instance at the same time,
               // this thread will not create the instance because another thread has created it in the meantime.
               // At the end, there is always a thread that creates the instance and this is what we expect.
-              throw OrthancException(ErrorCode_InternalError, HttpStatus_409_Conflict, "No new instance while overwriting; this might happen if another client has pushed the same instance at the same time.");
+
+              // Note, we must delete the attachments that have already been stored from this failed insertion (they have not yet been added into the DB)
+              throw OrthancException(ErrorCode_DuplicateResource, "No new instance while overwriting; this might happen if another client has pushed the same instance at the same time.");
             }
           }
           else