Last modified by Eleni Cojocariu on 2026/11/25 14:48

Show last authors
1 XWiki uses the READ COMMITTED transaction isolation level on MySQL and MariaDB, rather than the REPEATABLE READ level these databases default to. This page explains why, what it requires from the database server, and how to set another level.
2
3 == Why READ COMMITTED ==
4
5 What a request sees of the changes that other requests make at the same time depends on the isolation level. XWiki therefore uses the same level on every database, rather than each database's own default, so that the correctness of its code has to be reasoned about for one level only. That level is READ COMMITTED, at which every read sees the data committed when it runs. It is also the default level of PostgreSQL, Oracle and HSQLDB.
6
7 At REPEATABLE READ, every read of a transaction sees the database as it was at the transaction's first read instead, which XWiki's code doesn't expect. For example, when XWiki loads a page, it loads the classes of the page's objects in the same database transaction, so a class that another request saves while the page is loading is invisible to that load. XWiki then caches the class as missing, or in its previous version, and keeps it that way until the class is saved again or the wiki restarts: forms show no fields and sheets display empty values, although the class is intact in the database. This happens mostly when classes are saved on a wiki that is serving requests, for example while an extension is installed or upgraded.
8
9 == Which Level XWiki Uses ==
10
11 {{version since="17.10.14, 18.4.6, 18.8.0"}}
12 XWiki uses READ COMMITTED unless the ##hibernate.connection.isolation## property of ##WEB-INF/hibernate.cfg.xml## sets another level. XWiki applies that level to every database connection it opens, so the server's ##transaction_isolation## setting has no effect on it.
13 {{/version}}
14
15 {{version before="17.10.14, 18.4.6, 18.8.0"}}
16 XWiki uses the level set by the ##hibernate.connection.isolation## property of ##WEB-INF/hibernate.cfg.xml## and, when the property is not set, the level the database server defaults to: REPEATABLE READ, unless the server's ##transaction_isolation## setting says otherwise. [[Configure MySQL>>doc:documentation.xs.admin.installation.database.configure-mysql.WebHome]] shows the property value that makes XWiki use READ COMMITTED.
17 {{/version}}
18
19 == Binary Logging ==
20
21 InnoDB cannot record a write made at READ COMMITTED in a statement-based binary log, so a server configured with ##binlog_format=STATEMENT## rejects every write XWiki makes, as described in [["Impossible to write to binary log" MySQL Error>>doc:documentation.xs.admin.installation.database.configure-mysql.binlog-format-statement.WebHome]]. Binary logging therefore has to be either disabled or in the ##ROW## or ##MIXED## format. Both databases default to one of these: MySQL logs in the ##ROW## format and MariaDB in the ##MIXED## format.
22
23 == Setting Another Level ==
24
25 The ##hibernate.connection.isolation## property takes the JDBC number of the level:
26
27 |=Value |=Isolation level
28 |##1## |READ UNCOMMITTED
29 |##2## |READ COMMITTED
30 |##4## |REPEATABLE READ
31 |##8## |SERIALIZABLE
32
33 For example, to keep REPEATABLE READ, add the following property to ##WEB-INF/hibernate.cfg.xml## and restart XWiki:
34
35 {{code language="xml"}}
36 <property name="hibernate.connection.isolation">4</property>
37 {{/code}}
38
39 Only do this to work around a problem, such as a binary log that has to stay statement-based: XWiki's code is not designed for another level, which can cause problems such as the class caching described above.

Get Connected