Issue
- When setting up an environment that uses a read/write database split, it appears that Liferay tries to use Hypersonic (HSQL) instead of the configured database, as the startup logs note:
WARN [main][DialectDetector:100] Liferay is configured to use Hypersonic as its database. Do NOT use Hypersonic in production. Hypersonic is an embedded database useful for development and demonstration purposes. The database settings can be changed in portal-ext.properties.
INFO [main][DialectDetector:158] Using dialect com.liferay.portal.dao.orm.hibernate.HSQLDialect for HSQL Database Engine 2.3
INFO [main][DialectDetector:158] Using dialect org.hibernate.dialect.MySQLDialect for MySQL 5.7 - Since Hypersonic is not supported for Production, is it possible to know whether Liferay is currently using HSQL or MySQL in this environment? Is there a configuration change that can prevent the /hypersonic directory from being created and this logging from being seen during startup?
Environment
- DXP 7.1
Resolution
- To prevent the /hypersonic directory from being created and the HSQL messages from being logged, instead of removing the properties that start with
jdbc.default.*from the portal-ext.properties file during the read/write configuration steps, leave that set of properties present (un-commented) when adding thejdbc.read.*andjdbc.write.*properties, so all three sets are included. For example:
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:port/WriteDatabaseName?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&useFastDateParsing=false&useUnicode=true
jdbc.default.username=username
jdbc.default.password=password
jdbc.read.driverClassName=com.mysql.jdbc.Driver
jdbc.read.url=jdbc:mysql://localhost:port/ReadDatabaseName?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&useFastDateParsing=false&useUnicode=true
jdbc.read.username=username
jdbc.read.password=password
jdbc.write.driverClassName=com.mysql.jdbc.Driver
jdbc.write.url=jdbc:mysql://localhost:port/WriteDatabaseName?characterEncoding=UTF-8&dontTrackOpenResources=true&holdResultsOpenOverStatementClose=true&useFastDateParsing=false&useUnicode=true
jdbc.write.username=username
jdbc.write.password=password
... - Alternately, the HSQL message in the logs can be ignored, as Hypersonic is not used once the
jdbc.read.*andjdbc.write.*properties are picked up by the portal. If choosing this method, it may be beneficial to setsetup.wizard.enabled=falsewithin the portal-ext.properties file when starting up the bundle for the first time, as this will prevent the bundle from launching the setup wizard on first startup and encountering a "Default Database (Hypersonic)" note within the UI for that initial launch.
Additional Information
-
This behavior is observed due to the current design of the DBInitUtil class, which explicitly looks (when the
infrastructure-spring.xmlfile is loaded) for the portal properties that start withjdbc.default.*during startup (which are not necessarily present within the configured properties of an environment using a read/write split). Once thedynamic-data-source-infrastructure-spring.xmlis additionally loaded shortly thereafter, the portal is then able to recognize the additionaljdbc.read.*andjdbc.write.*properties, and uses the databases defined in those properties for portal operations. - Though the method to do so will vary by database vendor, transaction logging can be enabled in both the Read and Write databases (outside of Liferay) to verify whether the read and write transactions are using their associated respective databases as expected, if needed.
-
A feature request has been opened to look into restructuring the DBInitUtil class to wait for the
dynamic-data-source-infrastructure-spring.xmlfile to be additionally checked before the portal defaults to HSQL, and can be followed here: LPS-129633.