Bug 151 - Storage failures when running with two instances and PG_LOCK=false
Summary: Storage failures when running with two instances and PG_LOCK=false
Status: RESOLVED FIXED
Alias: None
Product: Orthanc
Classification: Unclassified
Component: Plugin - PostgreSQL (show other bugs)
Version: unspecified
Hardware: All All
: --- normal
Assignee: Sébastien Jodogne
URL:
Depends on:
Blocks:
 
Reported: 2020-06-29 15:16 CEST by Sébastien Jodogne
Modified: 2021-04-21 17:55 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sébastien Jodogne 2020-06-29 15:16:03 CEST
[BitBucket user: Felix Kiechle]
[BitBucket date: 2019-08-21.09:20:12]

**Setup**

* v. 19.6.4 with Postgres
* Running in a kubernetes cluster with 2 pods \(instances\)
* Both pods access the same Postresql database
* PG\_LOCK=false
* Rest of Postgresql parameters as described here in section “Example: using the postgresql plugin“ https://osimis.atlassian.net/wiki/spaces/OKB/pages/26738689/How+to+use+osimis+orthanc+Docker+images?showComments=true&showCommentArea=true

**Errors during study upload**

* `E0819 16:17:16.716238 ServerContext.cpp:425] Store failure`
* `E0819 16:17:10.987165 ServerIndex.cpp:990] EXCEPTION [Error with the database engine]`
* Not all images are successfully uploaded



When I scale down to one pod, all those errors disappear. Do I need to set `PG_LOCK=true`? I hoped it would be faster when setting to false. What is the recommended settings for Orthanc with Postgresql in a setup with multiple instances \(on the same database\)?
Comment 1 Sébastien Jodogne 2020-06-29 15:26:14 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-08-24.08:41:56]

Please check out the following explanation: bug 121

=> “When connecting multiple Orthanc to a single DB, there should only be one orthanc acting as a writer and all other orthanc instances acting as readers only. \[…\] You should set the option SaveJobs to false in the Orthanc configuration file \[in all the reader instances of Orthanc\].”

This is due to the fact that Orthanc does not currently support the replay of database transactions \(to deal with write conflicts\). This requires a deep refactoring, for which we are looking funding from the industry.
Comment 2 Sébastien Jodogne 2021-04-21 17:55:34 CEST
This is fixed by the following changeset, and will be part of forthcoming 4.0 release of the PostgreSQL plugins:
https://hg.orthanc-server.com/orthanc-databases/rev/567761f0c1ea