Last modified by Eleni Cojocariu on 2026/11/25 15:15

Show last authors
1 When a wiki misbehaves in a way that looks like damaged data rather than a slow query, a sanity check tells you whether the database holds rows XWiki itself could not have written: an object whose page was deleted, a property in the table of the wrong type, a translation with no original. It is a read-only report and it repairs nothing, so it is the first step of an investigation, not a fix; for where an instance keeps its data see [[XWiki Runtime Architecture>>doc:documentation.xs.admin.get-started.runtime-architecture.WebHome||anchor="HWhereaninstance27sstatelives"]].
2
3 1. Take the script for your database. Each one is a long list of ##SELECT## statements, none of which should return a row.(((
4 * [[sanitycheck.sql>>attach:sanitycheck.sql]] for MySQL and MariaDB, also reported to work on MS-SQL.
5 * [[sanitycheck-postgresql.sql>>attach:sanitycheck-postgresql.sql]] for PostgreSQL.
6
7 Read the comment block at the top of whichever you downloaded before running it. It records the XWiki version the script was last checked against and the three checks whose result needs interpreting on a current instance.
8 )))
9 1. Run it as the wiki's own database user, against the wiki's database. Nothing is written, so it is safe on a running instance, though on a large wiki it is a long sequence of full table scans and is better run when the wiki is quiet.(((
10 {{code language="bash"}}
11 mysql -u xwiki -p xwiki < sanitycheck.sql
12 {{/code}}
13
14 On PostgreSQL, pass ##-a##. The script labels its checks with SQL comments rather than with ##SELECT## statements, so without that flag ##psql## prints a column of anonymous result sets and nothing saying which check produced which.
15
16 {{code language="bash"}}
17 psql -U xwiki -d xwiki -a -f sanitycheck-postgresql.sql
18 {{/code}}
19 )))
20 1. Read the output against the three checks that need interpreting rather than acting on every row. Two of them report on a healthy instance, and the third depends on a setting.(((
21 |=Check|=What a row means today
22 |##attachment with no attachment content## and ##attachment with no attachment archive##|Nothing, on a default instance. Since XWiki 10.5 attachment content and its history live on the filesystem, so these two tables are empty by design and the checks select every attachment the wiki has. They only mean something where ##xwiki.store.attachment.hint## is set to ##hibernate##.
23 |##bad characters in document name##|Little, unless your wiki restricts page names. The check predates the Name Strategy feature and flags ##?##, ##+##, ##&##, ##### and a trailing space, none of which XWiki forbids; the standard flavor forbids only the backslash and the slash, and removes them silently.
24 |##similar document with different identifier##|A genuine duplicate: two rows for the same reference and language. These are worth investigating.
25 )))
26 1. Decide what the result means. A clean run prints the labels and no rows under them, which is the outcome to expect on a healthy wiki.(((
27 {{code language="none"}}
28 XWIKI SANITY CHECK
29 THIS SCRIPT SHOULD NOT SELECT ANY ROW
30
31 DOCUMENTS
32 checking for data with bad characters in document name
33
34 OBJECTS
35 checking for objects where the document does not exist anymore
36
37 ATTACHMENTS
38 checking for attachment where the document does not exist
39 {{/code}}
40
41 A row under a label is a thing to investigate with a backup in hand, not a thing to delete: the script names the table and the identifier, and nothing more. Take a [[backup>>doc:documentation.xs.admin.backup.WebHome]] before touching anything it reports.
42 )))

Get Connected