annotate Sphinx/source/plugins/postgresql.rst @ 1113:a588960a72e5 default tip

spelling
author Alain Mazy <am@orthanc.team>
date Mon, 28 Oct 2024 09:23:08 +0100
parents 69a318b7a58e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _postgresql:
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 PostgreSQL plugins
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 ==================
25fa874803ab plugins inside book
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
7 .. contents::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
8
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
9 The Orthanc project provides two **official** plugins to replace the
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
10 default storage area (on the filesystem) and the default SQLite index
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
11 by a PostgreSQL database.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
12
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
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
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
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
8b8df1be0cf9 documenting odbc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
19 The source code of the PostgreSQL plugins can be found in the
8b8df1be0cf9 documenting odbc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
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
8b8df1be0cf9 documenting odbc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
22 source code of the :ref:`ODBC <odbc>` and
8b8df1be0cf9 documenting odbc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
23 :ref:`MySQL/MariaDB <mysql>` plugins.
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
24
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
25
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
26 Compilation
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
27 -----------
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
28
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
29 Static linking
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
30 ^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
31
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
32 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
33
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
34 The procedure to compile these plugins is similar to that for the
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
35 :ref:`core of Orthanc <compiling>`. The following commands should work
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
36 for most UNIX-like distribution (including GNU/Linux)::
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
37
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
38 $ mkdir BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
39 $ cd BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
40 $ cmake ../PostgreSQL -DSTATIC_BUILD=ON -DCMAKE_BUILD_TYPE=Release
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
41 $ make
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
42
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
43 The compilation will produce 2 shared libraries, each containing one plugin for Orthanc:
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
44
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
45 * ``OrthancPostgreSQLIndex`` replaces the default SQLite index of Orthanc by PostgreSQL.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
46 * ``OrthancPostgreSQLStorage`` makes Orthanc store the DICOM files it receives into PostgreSQL.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
47
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
48
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
49 Microsoft Windows and Apple OS X
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
50 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
51
750
8b8df1be0cf9 documenting odbc
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 643
diff changeset
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
79b6d3ea92aa dicomweb
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 28
diff changeset
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
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
57
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
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
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
61 Dynamic linking on Ubuntu 16.04
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
62 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
63
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
64 .. highlight:: text
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
65
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
66 If static linking is not desired, here are build instructions for
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
67 Ubuntu 16.04 (provided build dependencies for the :ref:`core of
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
68 Orthanc <compiling>` have already been installed)::
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
69
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
70 $ sudo apt-get install libpq-dev postgresql-server-dev-all
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
71 $ mkdir BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
72 $ cd BuildPostgreSQL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
73 $ cmake ../PostgreSQL -DCMAKE_BUILD_TYPE=Release \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
74 -DALLOW_DOWNLOADS=ON \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
75 -DUSE_SYSTEM_GOOGLE_TEST=OFF \
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
76 -DUSE_SYSTEM_ORTHANC_SDK=OFF
128
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
77 $ make
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
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
84e3a2612c36 links to hg
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 358
diff changeset
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
f2abbac22d5c postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 118
diff changeset
102
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
103 Usage
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
104 -----
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
105
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
106 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
109 version above 0.9.5. You then have to **create a database** dedicated
28
dc235678897c webviewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 27
diff changeset
110 to Orthanc on some PostgreSQL server. Please refer to the `PostgreSQL
dc235678897c webviewer
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 27
diff changeset
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
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
113
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
114 Once Orthanc is installed and the database is created, you must add a
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
115 section in the :ref:`configuration file <configuration>` that
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
116 specifies the address of the **PostgreSQL server together with your
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
117 credentials**. You also have to tell Orthanc in which path it can find
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
118 the plugins: This is done by properly modifying the ``Plugins``
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
119 option. You could for instance adapt the following configuration
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
120 file::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
121
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
122 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
123 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
124 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
125 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
126 "EnableStorage" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
127 "Host" : "localhost",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
128 "Port" : 5432,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
129 "Database" : "orthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
130 "Username" : "orthanc",
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
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
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
135 "IndexConnectionsCount" : 1, // New in release 4.0
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
136 "TransactionMode": "Serializable", // New in release 6.0
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
137 "EnableVerboseLogs": false // New in release 6.0
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
138 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
139 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
140 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
141 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
142 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
143 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
144
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
145 **Important:** The ``EnableIndex`` and ``EnableStorage`` options must
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
146 be explicitly set to ``true``, otherwise Orthanc will continue to use
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
147 its default SQLite back-end and the filesystem storage area.
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
148
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
149 **Remark 1:** When using the ``Storage`` PostgreSQL plugin, the DICOM
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
150 files are stored as large objects in the database. This might
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
151 actually consume more space than the DICOM file itself. We have
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
152 observed overhead up to 40%. However, it seems this overhead is
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
153 temporary and comes from Write-Ahead Logging. Check this `discussion
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
154 <https://groups.google.com/d/msg/orthanc-users/pPzHOpb--iw/QkKZ808gIgAJ>`__
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
155 on the Orthanc Users group for more info).
118
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
156
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
157 **Remark 2:** A typical usage of the PostgreSQL plugin is to enable
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
158 only the ``Index``, and to use the default filesystem storage for
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
159 DICOM files (on a NAS with proper disaster recovery strategies). This
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
160 setup provides best performance for large-scale databases.
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
161
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
162 **Remark 3:** Setting the ``EnableSsl`` to ``true`` forces the use of
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
163 `SSL connections
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
164 <https://www.postgresql.org/docs/current/libpq-ssl.html>`__ between
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
165 Orthanc and the PostgreSQL server. It is a synonym for
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
166 ``sslmode=require`` in connections URI (see below). Setting
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
167 ``EnableSsl`` to ``false`` corresponds to ``sslmode=disable``
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
168 (i.e. SSL is not used, even if it is both available in Orthanc and
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
169 PostgreSQL). To choose other values for the SSL mode (i.e. ``allow``
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
170 and ``prefer``), please use connection URIs.
118
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
171
a30abf63ccba postgres: reference to forum for space usage
amazy
parents: 94
diff changeset
172
94
b0a71b880ca0 fix link + remark about disk usage overhead
Alain Mazy <alain@mazy.be>
parents: 81
diff changeset
173
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
174 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
175
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
176 Orthanc must of course be **restarted** after the modification of its
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
177 configuration file. The log will contain an output similar to::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
178
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
179 $ ./Orthanc Configuration.json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
180 W0212 16:30:34.576972 11285 main.cpp:632] Orthanc version: 0.8.6
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
181 W0212 16:30:34.577386 11285 OrthancInitialization.cpp:80] Using the configuration from: Configuration.json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
182 [...]
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
183 W0212 16:30:34.598053 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
184 W0212 16:30:34.598470 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-index' (version 1.0)
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
185 W0212 16:30:34.598491 11285 PluginsManager.cpp:148] Using PostgreSQL index
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
186 W0212 16:30:34.608289 11285 main.cpp:379] Registering a plugin from: /home/jodogne/Subversion/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
187 W0212 16:30:34.608916 11285 PluginsManager.cpp:258] Registering plugin 'postgresql-storage' (version 1.0)
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
188 W0212 16:30:34.608947 11285 PluginsManager.cpp:148] Using PostgreSQL storage area
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
189 [...]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
190 W0212 16:30:34.674648 11285 main.cpp:530] Orthanc has started
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
191
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
192
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
193 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
194
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
195 Instead of specifying explicit authentication parameters, you can also
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
196 use the `PostgreSQL connection URIs syntax
358
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
197 <https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING>`__. For
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
198 instance::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
199
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
200 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
201 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
202 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
203 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
204 "EnableStorage" : true,
181
c7551e19ae95 sslmode
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 154
diff changeset
205 "ConnectionUri" : "postgresql://username:password@localhost:5432/database?sslmode=prefer"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
206 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
207 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
208 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
209 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
210 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
211 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
212
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
213
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
214 **Remark:** The Debian Med project maintains `another useful set of
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
215 instructions
358
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
216 <https://salsa.debian.org/med-team/orthanc-postgresql/-/blob/master/debian/README.Debian>`__.
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
217
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
218
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
219 Advanced options
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
220 ----------------
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
221
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
222 Several advanced options are available as well to fine-tune the
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
223 configuration of the PostgreSQL plugins. They are documented below.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
224
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
225
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
226 .. _postgresql-multiple-writers:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
227
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
228 Multiple writers or connections
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
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
231 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
232 :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
233 <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
234 this behavior:
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
235
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
236 * ``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
237
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
238 * ``MaximumConnectionRetries`` governs how many times Orthanc tries to
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
239 connect to the database, as well as how many times Orthanc replays
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
240 transactions to deal with collisions between multiple writers in
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
241 ``Serializable`` transaction mode or with any transient transaction errors
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
242 in all transaction modes.
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
243
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
244 * ``IndexConnectionsCount`` controls the number of connections from
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
245 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
246 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
247
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
248 * ``ConnectionRetryInterval`` is only used when opening one database
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
249 connection to PostgreSQL.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
250
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
251 * ``TransactionMode`` has been added in the release 6.0. 2 values are
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
252 allowed: ``Serializable`` (that has always been the default mode for Orthanc)
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
253 and ``ReadCommitted`` that is available only from release 6.0. See
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
254 below.
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
255
643
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
256 * The PostgreSQL plugin supports the :ref:`revision mechanism
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
257 <revisions>` to protect metadata and attachments from concurrent
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
258 modifications.
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
259
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
260
411e82bb3a9f documenting revisions and multiple writers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 560
diff changeset
261
270
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
262 .. _postgresql-lock:
f29d75bc5c25 more info about database locking
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 263
diff changeset
263
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
264 Locking
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
265 ^^^^^^^
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
266
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
267 .. highlight:: json
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
268
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
269 By default, the plugins lock the database (using `PostgreSQL advisory
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
270 locks
358
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
271 <https://www.postgresql.org/docs/current/functions-admin.html#FUNCTIONS-ADVISORY-LOCKS>`__)
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
272 to prevent other instances of Orthanc from using the same PostgreSQL
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
273 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
274 database or if you need multiple connections to the PostgreSQL
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
275 database, set the ``Lock`` option to ``false`` in the configuration
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
276 file::
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
277
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
278 {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
279 "Name" : "MyOrthanc",
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
280 "PostgreSQL" : {
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
281 "EnableIndex" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
282 "EnableStorage" : true,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
283 "Lock" : false,
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
284 "ConnectionUri" : "postgresql://username:password@localhost:5432/database"
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
285 },
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
286 "Plugins" : [
154
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
287 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLIndex.so",
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 129
diff changeset
288 "/home/user/orthanc-databases/BuildPostgreSQL/libOrthancPostgreSQLStorage.so"
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
289 ]
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
290 }
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
291
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
292 Obviously, one must be very cautious when sharing the same database
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
293 between instances of Orthanc. In particular, all these instances
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
294 should share the same configuration.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
295
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
296
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
297 Keep-alive
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
298 ^^^^^^^^^^
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
299
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
300 .. highlight:: text
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
301
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
302 After some period of inactivity (users have reported 10 hours), you
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
303 might `experience an error
991
1316bc62b5d5 migration to UCLouvain servers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 750
diff changeset
304 <https://orthanc.uclouvain.be/bugs/show_bug.cgi?id=15>`__ such as::
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
305
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
306 E0220 03:20:51.562601 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: server closed the connection unexpectedly.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
307 This probably means the server terminated abnormally before or while processing the request.
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
308 E0220 06:51:03.924868 PluginsManager.cpp:163] Exception in database back-end: Error in PostgreSQL: no connection to the server
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
309
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
310 This is due to a timeout in the PostgreSQL server. Please make sure to
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
311 `enable keep-alive
358
011b01ccf52d fixing external hyperlinks
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 336
diff changeset
312 <https://dba.stackexchange.com/questions/97534/is-there-a-timeout-option-for-remote-access-to-postgresql-database>`__
27
c23f02a64caf postgresql
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 24
diff changeset
313 in the configuration of your PostgreSQL server
438
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
314
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
315
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
316 Scalability
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
317 ^^^^^^^^^^^
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
318
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
319 When configuring your PostgreSQL plugin, ensure you've read the :ref:`scalability section
5d6d593bceb6 scalability section
Alain Mazy <alain@mazy.be>
parents: 429
diff changeset
320 <scalability>`
531
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
321
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
322 Transaction modes (new in version 6.0)
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
323 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
324
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
325 .. highlight:: json
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
326
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
327 Starting from the release 6.0 of the plugin and Orthanc 1.12.3, orthanc supports 2 transaction modes that
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
328 can be configured in the ``TransactionMode`` configuration of the ``PostgreSQL`` plugin:
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
329
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
330 - ``Serializable`` in which all write transactions are serialized which might lead
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
331 to performance bottlenecks when lots of threads or Orthanc instances are trying
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
332 to write to the same Database.
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
333 - ``ReadCommitted`` that allows multiple threads or Orthanc instances to write at the
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
334 same time to the same Database.
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
335
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
336
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
337 Upgrades/Downgrades
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
338 ^^^^^^^^^^^^^^^^^^^
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
339
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
340 New vesions of the PostgreSQL might modify the DB schema by adding new columns/tables/triggers.
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
341 Upgrades from one revision to the other is always automatic.
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
342
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
343 However, if, for some reasons, you would like to reinstall a previous plugin version, the
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
344 older plugin might refuse to start because the revision is newer and unknown to it.
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
345
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
346 Starting from version 6.0 of the plugin, we are providing a downgrade script in case you want, e.g,
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
347 to reinstall Orthanc 1.12.3 and PostgreSQL 5.1 (whose DB schema is at revision 1).
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
348
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
349 To downgrade from revision 2 to revision 1, one might run this procedure::
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
350
1034
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
351 $ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/default/PostgreSQL/Plugins/SQL/Downgrades/Rev2ToRev1.sql
Alain Mazy <am@osimis.io>
parents: 1028
diff changeset
352 $ psql -U postgres -f Rev2ToRev1.sql
1016
02e04288bbeb pg-transactions
Alain Mazy <am@osimis.io>
parents: 993
diff changeset
353
1036
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
354 Note for large databases and multiple Orthanc instances:
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
355 """"""""""""""""""""""""""""""""""""""""""""""""""""""""
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
356
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
357 When upgrading from revision 1 to revision 2, the upgrade might take quite some time. E.g, we have observed the upgrade
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
358 taking 17 minutes on a DB with 300.000 studies and 150 millions instances. Orthanc will not respond during the upgrade. Therefore,
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
359 if you have enabled autohealing (automatic restart in case Orthanc is not responsive), you should likely disable it
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
360 during the first start with the PostgreSQL plugin v6.0.
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
361
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
362 Also note that, if you have multiple containers connected to the same DB, all containers will try to acquire an exclusive lock
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
363 to perform the upgrade of the DB. Only one of them will actually perform the upgrade. Also note that you should not perform a
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
364 rolling updates of the Orthanc containers when performing a DB upgrade. All Orthanc containers should use the same version of the
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
365 plugin, the one that is compatible with the current revision.
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
366
1037
Alain Mazy <am@osimis.io>
parents: 1036
diff changeset
367 Therefore, in complex setups, it might be simpler/safer to simply shut-down the Orthanc containers, perform the upgrade
1036
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
368 manually and then, restart the Orthanc containers with the newest version of the plugin.
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
369
1038
69a318b7a58e PG: schema
Alain Mazy <am@osimis.io>
parents: 1037
diff changeset
370 To upgrade manually from revision 1 to revision 2, one might run this procedure on the existing DB (note: make
69a318b7a58e PG: schema
Alain Mazy <am@osimis.io>
parents: 1037
diff changeset
371 sur to select the correct DB and schema (Orthanc is using the default ``public`` shema))::
1036
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
372
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
373 $ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/default/PostgreSQL/Plugins/SQL/Upgrades/Rev1ToRev2.sql
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
374 $ wget https://orthanc.uclouvain.be/hg/orthanc-databases/raw-file/default/PostgreSQL/Plugins/SQL/PrepareIndex.sql
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
375 $ psql -U postgres -f Rev1ToRev2.sql
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
376 $ psql -U postgres -f PrepareIndex.sql
b5f57cec7190 PG upgrades on large DB
Alain Mazy <am@osimis.io>
parents: 1034
diff changeset
377
1037
Alain Mazy <am@osimis.io>
parents: 1036
diff changeset
378 This procedure is identical to the one performed automatically by Orthanc when it detects that an upgraded is required.
Alain Mazy <am@osimis.io>
parents: 1036
diff changeset
379
Alain Mazy <am@osimis.io>
parents: 1036
diff changeset
380
531
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
381
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
382 Troubleshooting
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
383 ---------------
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
384
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
385 SCRAM authentication
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
386 ^^^^^^^^^^^^^^^^^^^^
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
387
560
5c0dfc863884 note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 531
diff changeset
388 .. 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
389 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
390 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
391 authentication.
5c0dfc863884 note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 531
diff changeset
392
5c0dfc863884 note for postgresql 3.3
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 531
diff changeset
393 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
394 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
395 (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
396 might not be compatible with more recent features of PostgreSQL.
531
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
397
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
398 In particular, the precompiled binaries are not compatible with `SCRAM
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
399 authentication
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
400 <https://en.wikipedia.org/wiki/Salted_Challenge_Response_Authentication_Mechanism>`__
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
401 that is available since PostgreSQL 10. If you get the error ``psql:
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
402 authentication method 10 not supported``, this indicates that the
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
403 PostgreSQL plugins cannot connect to a PostgreSQL server because SCRAM
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
404 is enabled.
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
405
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
406 `Ian Smith
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
407 <https://groups.google.com/g/orthanc-users/c/4EH7HpcEnSA/m/a4x6oiucAgAJ>`__
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
408 has reported the following method to disable SCRAM:
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
409
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
410 1. Drop/delete the ``orthanc`` database and user in PostgreSQL.
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
411 2. Edit the files ``postgresql.conf`` and ``pg_hba.conf`` and change
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
412 ``scram-sha-256`` to ``md5`` in all cases.
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
413 3. Add the ``orthanc`` user and database in PostgreSQL again.
fcf614950f31 disable scram
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 449
diff changeset
414 4. Restart Orthanc.