Mercurial > hg > orthanc-book
annotate Sphinx/source/plugins/postgresql.rst @ 1017:3f3a1b54a839
typo
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 19 Jan 2024 16:57:13 +0100 |
parents | 02e04288bbeb |
children | a3436ae3709c |
rev | line source |
---|---|
24 | 1 .. _postgresql: |
2 | |
3 | |
4 PostgreSQL plugins | |
5 ================== | |
6 | |
27 | 7 .. contents:: |
8 | |
9 The Orthanc project provides two **official** plugins to replace the | |
10 default storage area (on the filesystem) and the default SQLite index | |
11 by a PostgreSQL database. | |
12 | |
13 For general information, check out the `official homepage of the | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
14 plugins <https://www.orthanc-server.com/static.php?page=postgresql>`__. |
27 | 15 |
643
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
16 For information about scalability, make sure to read the section about |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
17 :ref:`multiple writers in large-scale deployments <multiple-writers>`. |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
18 |
750 | 19 The source code of the PostgreSQL plugins can be found in the |
20 ``orthanc-databases`` `Mercurial repository | |
991
1316bc62b5d5
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
750
diff
changeset
|
21 <https://orthanc.uclouvain.be/hg/orthanc-databases/>`__, next to the |
750 | 22 source code of the :ref:`ODBC <odbc>` and |
23 :ref:`MySQL/MariaDB <mysql>` plugins. | |
27 | 24 |
25 | |
26 Compilation | |
27 ----------- | |
28 | |
128 | 29 Static linking |
30 ^^^^^^^^^^^^^^ | |
31 | |
27 | 32 .. highlight:: text |
33 | |
154 | 34 The procedure to compile these plugins is similar to that for the |
27 | 35 :ref:`core of Orthanc <compiling>`. The following commands should work |
154 | 36 for most UNIX-like distribution (including GNU/Linux):: |
27 | 37 |
154 | 38 $ mkdir BuildPostgreSQL |
39 $ cd BuildPostgreSQL | |
40 $ cmake ../PostgreSQL -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release | |
27 | 41 $ make |
42 | |
43 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc: | |
44 | |
45 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL. | |
46 * ``OrthancPostgreSQLStorage`` makes Orthanc store the DICOM files it receives into PostgreSQL. | |
47 | |
128 | 48 |
49 Microsoft Windows and Apple OS X | |
50 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
51 | |
750 | 52 Pre-compiled binaries for Microsoft Windows 32bit `are also available |
993
05b106383b2a
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
53 <https://orthanc.uclouvain.be/downloads/windows-32/orthanc-postgresql/index.html>`__. |
30 | 54 A package for `Apple's Mac OS X |
993
05b106383b2a
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
55 <https://www.orthanc-server.com/static.php?page=download-mac>`__ |
05b106383b2a
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
56 is available courtesy of `Orthanc Team <https://orthanc.team/>`__. |
27 | 57 |
58 | |
263
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
59 .. _postgresql-ubuntu1604: |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
60 |
128 | 61 Dynamic linking on Ubuntu 16.04 |
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
63 | |
64 .. highlight:: text | |
65 | |
66 If static linking is not desired, here are build instructions for | |
67 Ubuntu 16.04 (provided build dependencies for the :ref:`core of | |
68 Orthanc <compiling>` have already been installed):: | |
69 | |
70 $ sudo apt-get install libpq-dev postgresql-server-dev-all | |
154 | 71 $ mkdir BuildPostgreSQL |
72 $ cd BuildPostgreSQL | |
73 $ cmake ../PostgreSQL -DCMAKE_BUILD_TYPE=Release \ | |
74 -DALLOW_DOWNLOADS=ON \ | |
75 -DUSE_SYSTEM_GOOGLE_TEST=OFF \ | |
76 -DUSE_SYSTEM_ORTHANC_SDK=OFF | |
128 | 77 $ make |
78 | |
263
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
79 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
80 .. _postgresql-cmake: |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
81 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
82 Dynamic linking on other GNU/Linux distributions |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
83 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
84 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
85 .. highlight:: text |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
86 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
87 The build instructions should always be very similar to those for |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
88 :ref:`Ubuntu 16.04 <postgresql-ubuntu1604>`. One difficulty that could |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
89 however arise is that it is possible that the CMake environment that |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
90 is shipped with the GNU/Linux distribution cannot locate a recent |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
91 version of the development headers for PostgreSQL. This leads to an |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
92 error while invoking CMake that looks like:: |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
93 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
94 -- Could NOT find PostgreSQL (missing: PostgreSQL_TYPE_INCLUDE_DIR) |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
95 |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
96 In such a situation, please add your version of PostgreSQL to the |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
97 macro ``PostgreSQL_ADDITIONAL_VERSIONS`` that is defined at the end of |
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
98 the `Resources/CMake/PostgreSQLConfiguration.cmake file |
991
1316bc62b5d5
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
750
diff
changeset
|
99 <https://orthanc.uclouvain.be/hg/orthanc-databases/file/default/Resources/CMake/PostgreSQLConfiguration.cmake>`__ |
361 | 100 in the sources of the project. |
263
39609c9a2c41
note about includes for postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
181
diff
changeset
|
101 |
128 | 102 |
27 | 103 Usage |
104 ----- | |
105 | |
106 .. highlight:: json | |
107 | |
31
93bbfaf0e62c
worklist instructions migrated to a specific page, indexing of Osimis Web viewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
30
diff
changeset
|
108 You of course first have to :ref:`install Orthanc <binaries>`, with a |
154 | 109 version above 0.9.5. You then have to **create a database** dedicated |
28 | 110 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL |
111 documentation | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
112 <https://www.postgresql.org/docs/current/tutorial-createdb.html>`__. |
27 | 113 |
114 Once Orthanc is installed and the database is created, you must add a | |
115 section in the :ref:`configuration file <configuration>` that | |
116 specifies the address of the **PostgreSQL server together with your | |
117 credentials**. You also have to tell Orthanc in which path it can find | |
118 the plugins: This is done by properly modifying the ``Plugins`` | |
119 option. You could for instance adapt the following configuration | |
120 file:: | |
121 | |
122 { | |
123 "Name" : "MyOrthanc", | |
124 "PostgreSQL" : { | |
125 "EnableIndex" : true, | |
126 "EnableStorage" : true, | |
127 "Host" : "localhost", | |
128 "Port" : 5432, | |
129 "Database" : "orthanc", | |
130 "Username" : "orthanc", | |
181 | 131 "Password" : "orthanc", |
643
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
132 "EnableSsl" : false, // New in release 3.0 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
133 "MaximumConnectionRetries" : 10, // New in release 3.0 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
134 "ConnectionRetryInterval" : 5, // New in release 3.0 |
1016 | 135 "IndexConnectionsCount" : 1, // New in release 4.0 |
136 "TransactionMode": "SERIALIZABLE" // New in beta version (not released yet) | |
27 | 137 }, |
138 "Plugins" : [ | |
154 | 139 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
140 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 141 ] |
142 } | |
143 | |
154 | 144 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must |
145 be explicitly set to ``true``, otherwise Orthanc will continue to use | |
146 its default SQLite back-end and the filesystem storage area. | |
27 | 147 |
181 | 148 **Remark 1:** When using the ``Storage`` PostgreSQL plugin, the DICOM |
154 | 149 files are stored as large objects in the database. This might |
150 actually consume more space than the DICOM file itself. We have | |
151 observed overhead up to 40%. However, it seems this overhead is | |
152 temporary and comes from Write-Ahead Logging. Check this `discussion | |
153 <https://groups.google.com/d/msg/orthanc-users/pPzHOpb--iw/QkKZ808gIgAJ>`__ | |
154 on the Orthanc Users group for more info). | |
118 | 155 |
181 | 156 **Remark 2:** A typical usage of the PostgreSQL plugin is to enable |
157 only the ``Index``, and to use the default filesystem storage for | |
158 DICOM files (on a NAS with proper disaster recovery strategies). This | |
159 setup provides best performance for large-scale databases. | |
160 | |
161 **Remark 3:** Setting the ``EnableSsl`` to ``true`` forces the use of | |
162 `SSL connections | |
163 <https://www.postgresql.org/docs/current/libpq-ssl.html>`__ between | |
164 Orthanc and the PostgreSQL server. It is a synonym for | |
165 ``sslmode=require`` in connections URI (see below). Setting | |
166 ``EnableSsl`` to ``false`` corresponds to ``sslmode=disable`` | |
167 (i.e. SSL is not used, even if it is both available in Orthanc and | |
168 PostgreSQL). To choose other values for the SSL mode (i.e. ``allow`` | |
169 and ``prefer``), please use connection URIs. | |
118 | 170 |
171 | |
94
b0a71b880ca0
fix link + remark about disk usage overhead
Alain Mazy <alain@mazy.be>
parents:
81
diff
changeset
|
172 |
27 | 173 .. highlight:: text |
174 | |
175 Orthanc must of course be **restarted** after the modification of its | |
176 configuration file. The log will contain an output similar to:: | |
177 | |
178 $ ./Orthanc Configuration.json | |
179 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6 | |
180 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json | |
181 [...] | |
154 | 182 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so |
27 | 183 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0) |
184 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index | |
154 | 185 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so |
27 | 186 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0) |
187 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area | |
188 [...] | |
189 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started | |
190 | |
191 | |
192 .. highlight:: json | |
193 | |
194 Instead of specifying explicit authentication parameters, you can also | |
195 use the `PostgreSQL connection URIs syntax | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
196 <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING>`__. For |
27 | 197 instance:: |
198 | |
199 { | |
200 "Name" : "MyOrthanc", | |
201 "PostgreSQL" : { | |
202 "EnableIndex" : true, | |
203 "EnableStorage" : true, | |
181 | 204 "ConnectionUri" : "postgresql://username:password@localhost:5432/database?sslmode=prefer" |
27 | 205 }, |
206 "Plugins" : [ | |
154 | 207 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
208 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 209 ] |
210 } | |
211 | |
212 | |
213 **Remark:** The Debian Med project maintains `another useful set of | |
214 instructions | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
215 <https://salsa.debian.org/med-team/orthanc-postgresql/-/blob/master/debian/README.Debian>`__. |
27 | 216 |
217 | |
218 Advanced options | |
219 ---------------- | |
220 | |
221 Several advanced options are available as well to fine-tune the | |
222 configuration of the PostgreSQL plugins. They are documented below. | |
223 | |
224 | |
643
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
225 .. _postgresql-multiple-writers: |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
226 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
227 Multiple writers or connections |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
228 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
229 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
230 Starting with Orthanc 1.9.2 and PostgreSQL 4.0, it is possible to use |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
231 :ref:`multiple writers or connections in large-scale deployments |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
232 <multiple-writers>`. Here is the list of configuration that control |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
233 this behavior: |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
234 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
235 * ``Lock`` must be set to ``false`` (cf. :ref:`below <postgresql-lock>`) |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
236 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
237 * ``MaximumConnectionRetries`` governs how many times Orthanc tries to |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
238 connect to the database, as well as how many times Orthanc replays |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
239 transactions to deal with collisions between multiple writers. |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
240 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
241 * ``IndexConnectionsCount`` controls the number of connections from |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
242 the index plugin to the PostgreSQL database. It is set to ``1`` by |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
243 default, which corresponds to the old behavior of Orthanc <= 1.9.1. |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
244 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
245 * ``ConnectionRetryInterval`` is only used when opening one database |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
246 connection to PostgreSQL. |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
247 |
1016 | 248 * ``TransactionMode`` has been added in the ``pg-transactions`` beta version only. 2 values are |
249 allowed: ``SERIALIZABLE`` (that has always been the default mode for Orthanc) | |
250 and ``READ COMMITTED`` that is available only from this beta version. See | |
251 below. | |
252 | |
643
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
253 * The PostgreSQL plugin supports the :ref:`revision mechanism |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
254 <revisions>` to protect metadata and attachments from concurrent |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
255 modifications. |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
256 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
257 |
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
258 |
270
f29d75bc5c25
more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
259 .. _postgresql-lock: |
f29d75bc5c25
more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
263
diff
changeset
|
260 |
27 | 261 Locking |
262 ^^^^^^^ | |
263 | |
264 .. highlight:: json | |
265 | |
266 By default, the plugins lock the database (using `PostgreSQL advisory | |
267 locks | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
268 <https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS>`__) |
27 | 269 to prevent other instances of Orthanc from using the same PostgreSQL |
270 database. If you want several instances of Orthanc to share the same | |
643
411e82bb3a9f
documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
560
diff
changeset
|
271 database or if you need multiple connections to the PostgreSQL |
27 | 272 database, set the ``Lock`` option to ``false`` in the configuration |
273 file:: | |
274 | |
275 { | |
276 "Name" : "MyOrthanc", | |
277 "PostgreSQL" : { | |
278 "EnableIndex" : true, | |
279 "EnableStorage" : true, | |
280 "Lock" : false, | |
281 "ConnectionUri" : "postgresql://username:password@localhost:5432/database" | |
282 }, | |
283 "Plugins" : [ | |
154 | 284 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so", |
285 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so" | |
27 | 286 ] |
287 } | |
288 | |
289 Obviously, one must be very cautious when sharing the same database | |
290 between instances of Orthanc. In particular, all these instances | |
291 should share the same configuration. | |
292 | |
293 | |
294 Keep-alive | |
295 ^^^^^^^^^^ | |
296 | |
297 .. highlight:: text | |
298 | |
299 After some period of inactivity (users have reported 10 hours), you | |
300 might `experience an error | |
991
1316bc62b5d5
migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
750
diff
changeset
|
301 <https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=15>`__ such as:: |
27 | 302 |
303 E0220 03:20:51.562601 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: server closed the connection unexpectedly. | |
304 This probably means the server terminated abnormally before or while processing the request. | |
305 E0220 06:51:03.924868 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: no connection to the server | |
306 | |
307 This is due to a timeout in the PostgreSQL server. Please make sure to | |
308 `enable keep-alive | |
358
011b01ccf52d
fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
336
diff
changeset
|
309 <https://dba.stackexchange.com/questions/97534/is-there-a-timeout-option-for-remote-access-to-postgresql-database>`__ |
27 | 310 in the configuration of your PostgreSQL server |
438 | 311 |
312 | |
313 Scalability | |
314 ^^^^^^^^^^^ | |
315 | |
316 When configuring your PostgreSQL plugin, ensure you've read the :ref:`scalability section | |
317 <scalability>` | |
531 | 318 |
1016 | 319 Transaction modes (``pg-transactions`` beta version only) |
320 ^^^^^^^^^^^^^^^^^ | |
321 | |
322 .. highlight:: json | |
323 | |
324 Starting from the current beta version, orthanc supports 2 transaction modes that | |
325 can be configured in the ``TransactionMode`` configuration of the ``PostgreSQL`` plugin: | |
326 | |
327 - ``SERIALIZABLE`` in which all write transactions are serialized which might lead | |
328 to performance bottlenecks when lots of threads or Orthanc instances are trying | |
329 to write to the same Database. | |
1017 | 330 - ``READ COMMITTED`` that allows multiple threads or Orthanc instances to write at the |
1016 | 331 same time to the same Database. |
332 | |
333 *Remark:* This feature is only available in a beta version of both Orthanc and the | |
334 PostgreSQL plugin (``pg-transactions`` branches in the code). This beta version is | |
335 only available in the ``osimis/orthanc:pg-transactions-unstable`` Docker image. | |
336 | |
337 *Remark:* This beta version is really a beta version and **should not be used on a | |
338 production database**. It shall only be used on a DB that you can delete or recover. | |
339 The reason why it shall not be used on a production database is because this revision | |
340 modifies the DB schema to a :ref:`version <db-versioning>`/revision ``6.2`` that might be different from the | |
341 final schema of the future release although it will share the same version/revision. | |
342 We can not guarantee to maintain migration scripts from this temporary schema to the final | |
343 one. | |
344 | |
345 Upgrades/Downgrades (``pg-transactions`` beta version only) | |
346 ^^^^^^^^^^^^^^^^^ | |
347 | |
348 New vesions of the PostgreSQL might modify the DB schema by adding new columns/tables/triggers. | |
349 Upgrades from one revision to the other is always automatic. | |
350 | |
351 However, if, for some reasons, you would like to reinstall a previous plugin version, the | |
352 older plugin might refuse to start because the revision is newer and unknown to it. | |
353 | |
354 Starting from this beta version, we are providing a downgrade script in case you want, e.g, | |
355 to reinstall Orthanc 1.12.2 and PostgreSQL 5.1 (DB schema revision 6.1). | |
356 | |
357 To downgrade from the beta to the PostgreSQL 5.1, one might run this procedure:: | |
358 | |
359 $ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/pg-transactions/PostgreSQL/Plugins/SQL/Downgrades/V6.2ToV6.1.sql | |
360 $ psql -U postgres -f V6.2ToV6.1.sql | |
361 | |
531 | 362 |
363 Troubleshooting | |
364 --------------- | |
365 | |
366 SCRAM authentication | |
367 ^^^^^^^^^^^^^^^^^^^^ | |
368 | |
560
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
369 .. note:: This section only applies to releases <= 3.2 of the |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
370 PostgreSQL plugins. Starting with release 3.3, the plugins |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
371 use a version of libpq that should support SCRAM |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
372 authentication. |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
373 |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
374 In the releases 3.2 of the PostgreSQL plugins, the precompiled |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
375 binaries use an old, but stable version of the PostgreSQL client |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
376 (libpq 9.6.1). This makes these binaries very portable, however they |
5c0dfc863884
note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
531
diff
changeset
|
377 might not be compatible with more recent features of PostgreSQL. |
531 | 378 |
379 In particular, the precompiled binaries are not compatible with `SCRAM | |
380 authentication | |
381 <https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism>`__ | |
382 that is available since PostgreSQL 10. If you get the error ``psql: | |
383 authentication method 10 not supported``, this indicates that the | |
384 PostgreSQL plugins cannot connect to a PostgreSQL server because SCRAM | |
385 is enabled. | |
386 | |
387 `Ian Smith | |
388 <https://groups.google.com/g/orthanc-users/c/4EH7HpcEnSA/m/a4x6oiucAgAJ>`__ | |
389 has reported the following method to disable SCRAM: | |
390 | |
391 1. Drop/delete the ``orthanc`` database and user in PostgreSQL. | |
392 2. Edit the files ``postgresql.conf`` and ``pg_hba.conf`` and change | |
393 ``scram-sha-256`` to ``md5`` in all cases. | |
394 3. Add the ``orthanc`` user and database in PostgreSQL again. | |
395 4. Restart Orthanc. |