|
| Description: |
h2. 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: {noformat} 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) {noformat} This happens on every upgrade functional test starting from data that contains the legacy activity stream table (Upgrade84Test, Upgrade84FileStoreTest, Upgrade911Test, Upgrade1011Test, Upgrade1110Test, Upgrade1210CustomTest).
h2. 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}} / , {{ mailsender feeds . oracle. hbm.xml}} , ...) have no column in that range and are not affected. * {{feeds h2 . hbm Affected instances
Instances using HSQLDB or Oracle on which those tables were created before XWiki 13 . xml}} / 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 {{ feeds R130200001XWIKI18429DataMigration}} (13 . oracle 2 to 13 . hbm 10 . xml 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.
h2. 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}}. |
|