How does Orthanc deal with concurrent access to the database backend?

Does anyone know how Orthanc addresses concurrent access to the backend database? I have been reading the source but I figured it would be more effective to just ask. Specifically, I am using the PostgreSQL plugin. Does Orthanc take advantage of Postgres transactions to handle concurrent database operations or some other method? Or does it just execute all the database commands synchronously?


Orthanc simultaneously uses two distinct database backends: the one storing the DICOM/JSON files (the “attachment database”), and the one storing the actual “index database” (the DICOM hierarchy, the main DICOM tags…). More explanation is available in the Orthanc Book:

The “attachment database” is accessed concurrently by Orthanc (there is no locking, no mutual exclusion). This allows simultaneous retrieving of DICOM/JSON files if needed by multiple DICOM connections or by multiple REST calls.

The “index database” is accessed synchronously by Orthanc (there is mutual exclusion). This simpler design is motivated by the fact that, in the case of a Vendor Neutral Archive such as Orthanc, the server spends most of its time waiting for the retrieval of files from the “attachment database”, whereas the accesses to the “index database” are brief.

Note however that, in the official PostgreSQL plugin, each access to the “index database” is properly isolated in a transaction. As a consequence, If needed, scalability can be achieved by deploying several instances of Orthanc accessing the same PostgreSQL databases. Check out the “Locking” parameter of the plugins: