Wiki source code of Switch to the Database Attachment Store
Last modified by Eleni Cojocariu on 2026/09/25 02:48
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | Switch the wiki to the database attachment store, which keeps attachment content in the database instead of on disk, one of the two stores [[The Attachment Store>>doc:documentation.xs.admin.store.attachment-store.WebHome]] compares. | ||
| 2 | |||
| 3 | {{warning}} | ||
| 4 | On MySQL, raise ##max_allowed_packet## before you start. The content of an attachment and its whole version history are written as single values, in one query, so plan on about three times the size of your largest attachment, and more where attachments have long histories. [[Packet for query is too large>>doc:documentation.xs.admin.installation.methods.install-xwiki-war.install-relational-database.configure-mysql.max-allowed-packet.WebHome]] is what a value set too low looks like. | ||
| 5 | {{/warning}} | ||
| 6 | |||
| 7 | 1. Stop XWiki. | ||
| 8 | 1. Open ##xwiki/WEB-INF/xwiki.cfg## and set the four storage hints to ##hibernate##:((( | ||
| 9 | {{code language="properties"}} | ||
| 10 | xwiki.store.attachment.hint=hibernate | ||
| 11 | xwiki.store.attachment.versioning.hint=hibernate | ||
| 12 | xwiki.store.attachment.recyclebin.content.hint=hibernate | ||
| 13 | xwiki.store.recyclebin.content.hint=hibernate | ||
| 14 | {{/code}} | ||
| 15 | |||
| 16 | All four ship commented out, so uncommenting them is part of the change: a line left commented keeps its default whatever value you wrote on it. The last of the four is the store for deleted Pages rather than for deleted attachments, and it belongs here because a Page carries its attachments with it into the recycle bin. | ||
| 17 | ))) | ||
| 18 | 1. Start XWiki again. | ||
| 19 | 1. Attach a file to any Page, then look for its content in the database:((( | ||
| 20 | {{code language="sql"}} | ||
| 21 | SELECT COUNT(*) FROM xwikiattachment_content; | ||
| 22 | {{/code}} | ||
| 23 | |||
| 24 | The table gains a row, the file you have just attached. It does not gain a row for every attachment already in the wiki, and nothing new appears under ##store/file## in the permanent directory: the older attachments are still on disk, exactly as they were. | ||
| 25 | ))) | ||
| 26 | |||
| 27 | From here on the wiki is under the size ceiling of the database store: an attachment much larger than 30 MB cannot be saved, for the reason [[The Attachment Store>>doc:documentation.xs.admin.store.attachment-store.WebHome]] gives. |