annotate Sphinx/source/faq/orthanc-storage.rst @ 46:12b204ee328d

remark about replication
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 07 Oct 2016 08:07:24 +0200
parents 38fb7bf24794
children 365427cebb64
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46
12b204ee328d remark about replication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 37
diff changeset
1 .. _orthanc-storage:
12b204ee328d remark about replication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 37
diff changeset
2
37
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 36
diff changeset
3 How does Orthanc store its database?
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 36
diff changeset
4 ====================================
35
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 Storage folder
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 --------------
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 **By default** (i.e. if no database plugin such as :ref:`PostgreSQL
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 <postgresql>` is used), Orthanc stores all the DICOM files it receives
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 in a folder called ``OrthancStorage`` on the filesystem. Orthanc also
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 associates each incoming DICOM file with a JSON file that summarizes
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 all its DICOM tags, which speeds up subsequent processing by avoiding
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 a costly DICOM parsing.
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 More generally, the ``OrthancStorage`` folder contains a set of
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 so-called **attachments**, that may correspond to either a DICOM file,
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 a JSON file, or any user-defined file. Internally, each attachment is
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 automatically associated with an `universally unique identifier (UUID)
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 <https://en.wikipedia.org/wiki/Universally_unique_identifier>`__.
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 Orthanc can be configured to compress these files on-the-fly in order
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 to save disk space (cf. the ``StorageCompression`` :ref:`configuration
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 option <configuration>`).
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 To reduce the number of files in a single directory (which is
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 something that some operating systems might not like), a 3-level
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 hierarchy of directories is created to store the attachments: The
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 first two hexadecimal characters of the UUID give the first-level
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 folder, and the two next characters give the second-level folder.
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 SQLite index
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 ------------
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 Inside the same ``OrthancStorage`` folder, Orthanc maintains a `SQLite
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 database <https://en.wikipedia.org/wiki/SQLite>`__ called ``index``
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 that **indexes** all these attachments. The database records, for each
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 attachment, its compression method, and its MD5 hashes before and
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 after compression in order to detect disk corruption (cf. the
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 ``StoreMD5ForAttachments`` :ref:`configuration option
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 <configuration>`).
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 One attachment must be associated with one :ref:`DICOM resource
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 <model-world>` (patient, study, series, or instance). Incoming DICOM
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 files and associated JSON summary are associated with one
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 instance-level resource, but user-defined attachments can be
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 associated with any kind of resource.
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 Given one DICOM resource, all of its child attachments are identified
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 by a number between 0 and 65535. Identifiers <= 1023 are reserved for
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 the Orthanc core, whereas identifiers >= 1024 can be user-defined for
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 external applications.
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 Direct access
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 -------------
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 Directly accessing the content of the ``OrthancStorage`` folder and
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 the content of the SQLite database is strongly discouraged for several
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 reasons:
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 * This internal organization is only true when no database plugin is
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 used (e.g. the :ref:`PostgreSQL plugin <postgresql>` can be
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 configured to store the attachments inside a database).
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 * Orthanc can be configured to compress the attachments before writing
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 them on the disk (cf. the ``StorageCompression`` option).
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 * By directly reading the content of ``OrthancStorage``, you bypass
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 all the locking mechanisms used by Orthanc, which might result in
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 data corruption.
36
6474af38dcbd SQLITE_BUSY
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 35
diff changeset
70 * One SQLite database should be accessed by at most one process at any
6474af38dcbd SQLITE_BUSY
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 35
diff changeset
71 time to avoid any problem (e.g. with NFS filesystems), for reasons
6474af38dcbd SQLITE_BUSY
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 35
diff changeset
72 that are `explained in the SQLite FAQ
6474af38dcbd SQLITE_BUSY
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 35
diff changeset
73 <https://www.sqlite.org/faq.html#q5>`__. Orthanc will stop if it
6474af38dcbd SQLITE_BUSY
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 35
diff changeset
74 receives the ``SQLITE_BUSY`` status.
35
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 As a consequence, it is **HIGHLY recommended NOT to directly access**
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 the ``OrthancStorage`` folder and the SQLite database. Use the
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 :ref:`REST API <rest>` instead, which contains primitives to access
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 the attachments (cf. the ``.../attachments/...`` URIs).
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 The only exception to this rule is for **read-only access when Orthanc
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 is stopped**, e.g. as a part of a :ref:`backup <backup>` or
5737f51ff94e How does Orthanc stores its database
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 :ref:`upgrade/replication <replication>` process.