Details
-
Bug
-
Resolution: Unresolved
-
Major
-
13.2-rc-1
-
Unknown
-
Description
Problem
On HSQLDB and Oracle, the migration that increases the size of the columns to 768 characters (introduced by XWIKI-18429 and XWIKI-18497, currently executed by R140200010XWIKI19207DataMigration through AbstractResizeMigration) silently skips every column whose Hibernate mapping declares a lowercase column name. Those columns keep their old size of 255 characters on instances created before XWiki 13.2.
As a consequence, saving a value longer than 255 characters in one of those columns fails. For example, with the legacy activity stream store, an event about a page whose reference is longer than 255 characters cannot be saved:
ERROR o.h.e.j.s.SqlExceptionHelper - data exception: string data, right truncation ; size limit: 255 table: ACTIVITYSTREAM_EVENTS column: ASE_PAGE ERROR .x.x.s.XWikiHibernateBaseStore - Exception while closing the transaction javax.persistence.PersistenceException: org.hibernate.exception.DataException: could not execute statement at org.xwiki.eventstream.store.internal.LegacyEventSaver.saveLegacyEvent(LegacyEventSaver.java:94)
This happens on every upgrade functional test starting from data that contains the legacy activity stream table (Upgrade84Test, Upgrade84FileStoreTest, Upgrade911Test, Upgrade1011Test, Upgrade1110Test, Upgrade1210CustomTest).
Cause
AbstractResizeMigration reads the current size of each column with DatabaseMetaData#getColumns, using HibernateStore#getConfiguredColumnName(Column) for the column name. That method only adjusts the case for PostgreSQL. The table name goes through HibernateAdapter#getTableName, which uppercases it for HSQLDB and Oracle, but the column name is passed as written in the mapping. HSQLDB and Oracle store unquoted identifiers in uppercase, so a lowercase column name such as ase_page is not found, the migration considers that the column does not exist, and skips it.
Columns declared in uppercase (for example all the xwiki.hbm.xml columns like XWD_FULLNAME) are found and resized, which is why the problem only affects some tables. The migration only handles the columns mapped with a length between 720 and 768, and the mappings using lowercase column names which have such columns are:
- eventstream.hbm.xml / eventstream.oracle.hbm.xml (legacy activity stream tables: 8 columns)
- notification-filter-preferences.hbm.xml (notification filter preferences table: 5 columns)
The other mappings using lowercase column names (mailsender.hbm.xml, feeds.hbm.xml, ...) have no column in that range and are not affected.
Affected instances
Instances using HSQLDB or Oracle on which those tables were created before XWiki 13.2. The size of these columns was increased in the mapping in 13.2 (XWIKI-18429, XWIKI-18497) and has not changed since, so tables created on 13.2 or later already have the right size. On older tables, neither R130200001XWIKI18429DataMigration (13.2 to 13.10.1) nor R140200010XWIKI19207DataMigration (which replaced it) could find these columns, since both resolve the column names the same way.
Confirmed by running Upgrade1210CustomTest with extra logging in AbstractResizeMigration: the LegacyEvent entity is found (ACTIVITYSTREAM_EVENTS exists) but the database size of all its columns is null.
MySQL/MariaDB (case-insensitive column lookup) and PostgreSQL (lowercased explicitly) are not affected.
Expected
The column names are resolved with the same case rules as the table names, and a new migration resizes the columns that were skipped on instances which already executed R140200010XWIKI19207.
Attachments
Issue Links
- relates to
-
XWIKI-19276 Cannot update to XWiki 13.10.2: "Index column size too large. The maximum column size is 767 bytes"
-
- Closed
-
-
XWIKI-18497 Missing 255 -> 768 column size increase
-
- Closed
-
-
XWIKI-19207 Increase the limit of the parent size to the maximum supported by MySQL
-
- Closed
-
-
XWIKI-18429 Increase the limit of the document reference size to the maximum supported by MySQL
-
- Closed
-