comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 5456:06eb8bc9f024 pg-transactions

raise 409 if multiple clients are writing the same instance at the same time
author Alain Mazy <am@osimis.io>
date Fri, 08 Dec 2023 09:18:44 +0100
parents 176bc05f85f4
children 38f1d06875ad
comparison
equal deleted inserted replaced
5455:176bc05f85f4 5456:06eb8bc9f024
3151 3151
3152 // Re-create the instance, now that the old one is removed 3152 // Re-create the instance, now that the old one is removed
3153 if (!transaction.CreateInstance(status, instanceId, hashPatient_, 3153 if (!transaction.CreateInstance(status, instanceId, hashPatient_,
3154 hashStudy_, hashSeries_, hashInstance_)) 3154 hashStudy_, hashSeries_, hashInstance_))
3155 { 3155 {
3156 throw OrthancException(ErrorCode_InternalError, "No new instance while overwriting; this should not happen."); 3156 // Note that, sometime, it does not create a new instance,
3157 // in very rare occasions in READ COMMITTED mode when multiple clients are pushing the same instance at the same time,
3158 // this thread will not create the instance because another thread has created it in the meantime.
3159 // At the end, there is always a thread that creates the instance and this is what we expect.
3160 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.");
3157 } 3161 }
3158 } 3162 }
3159 else 3163 else
3160 { 3164 {
3161 // Do nothing if the instance already exists and overwriting is disabled 3165 // Do nothing if the instance already exists and overwriting is disabled