Mercurial > hg > orthanc
comparison OrthancServer/Sources/Database/StatelessDatabaseOperations.cpp @ 4801:23aeffecb8cb
Fix instances accumulating in DB while their attachments were not stored because of MaximumStorageSize limit reached with a single patient in DB.
author | Alain Mazy <am@osimis.io> |
---|---|
date | Tue, 19 Oct 2021 15:29:48 +0200 |
parents | 569d9ef165b1 |
children | 70d2a97ca8cb 7053502fbf97 |
comparison
equal
deleted
inserted
replaced
4800:588fa6fb32ca | 4801:23aeffecb8cb |
---|---|
2808 transaction_.SelectPatientToRecycle(patientToRecycle, patientToAvoid) : | 2808 transaction_.SelectPatientToRecycle(patientToRecycle, patientToAvoid) : |
2809 transaction_.SelectPatientToRecycle(patientToRecycle)); | 2809 transaction_.SelectPatientToRecycle(patientToRecycle)); |
2810 | 2810 |
2811 if (!ok) | 2811 if (!ok) |
2812 { | 2812 { |
2813 throw OrthancException(ErrorCode_FullStorage); | 2813 throw OrthancException(ErrorCode_FullStorage, "Cannot recycle more patients"); |
2814 } | 2814 } |
2815 | 2815 |
2816 LOG(TRACE) << "Recycling one patient"; | 2816 LOG(TRACE) << "Recycling one patient"; |
2817 transaction_.DeleteResource(patientToRecycle); | 2817 transaction_.DeleteResource(patientToRecycle); |
2818 | 2818 |
3262 } | 3262 } |
3263 catch (OrthancException& e) | 3263 catch (OrthancException& e) |
3264 { | 3264 { |
3265 if (e.GetErrorCode() == ErrorCode_DatabaseCannotSerialize) | 3265 if (e.GetErrorCode() == ErrorCode_DatabaseCannotSerialize) |
3266 { | 3266 { |
3267 throw; | 3267 throw; // the transaction has failed -> do not commit the current transaction (and retry) |
3268 } | 3268 } |
3269 else | 3269 else |
3270 { | 3270 { |
3271 LOG(ERROR) << "EXCEPTION [" << e.What() << "]"; | 3271 LOG(ERROR) << "EXCEPTION [" << e.What() << " - " << e.GetDetails() << "]"; |
3272 | |
3273 if (e.GetErrorCode() == ErrorCode_FullStorage) | |
3274 { | |
3275 throw; // do not commit the current transaction | |
3276 } | |
3277 | |
3278 // this is an expected failure, exit normaly and commit the current transaction | |
3272 storeStatus_ = StoreStatus_Failure; | 3279 storeStatus_ = StoreStatus_Failure; |
3273 } | 3280 } |
3274 } | 3281 } |
3275 } | 3282 } |
3276 }; | 3283 }; |