What is Database Sharding ?
Database Sharding is an approach of partitioning a database horizontally. Each individual part is referred to as a shard. Using this approach, total number of rows in each table is reduced resulting into improved search performance and we can achieve separation of data. Liferay supports database sharding. It allows you to run multiple portal instances on the same server and data of each portal instance is kept separated from each other. However, there are several issues present in the implementation of database sharding in Liferay 6.2. I am listing out a couple of them with proposed solutions.
Issue 1: Newly created user can not login to portal.
Steps to reproduce issue:
Create a new portal instance in Liferay.
Create a user account in the new portal instance.
Log in with the password generated by Liferay.
When you try to login, an exception is thrown and browser displays an error message as follows : com.liferay.portal.NoSuchContactException: No Contact exists with the primary key 14003.
This exception is thrown because database cache is not refreshed after creating a new user. Which means user record(‘Contact’ entity) is present in database but not in database cache, so Liferay throws an exception.
-Log in to default instance as an omni administrator user.
-Go to Admin -> Control Panel -> Server Administration -> Resources.
-Click on “Execute” of option “Clear the database cache”.
Issue 2: “Add” dropdown button does not appear in Document and media portlet.
Steps to reproduce issue:
Create new portal instance with database sharding implemented.
Add “Document and Media” portlet in a page.
“ADD” dropdown button disappears from the portlet that is on the page of portal instances(other than default instance) at random times.
When sharding is used with multiple databases, each database contains Liferay generated tables. For the default instance, there are 5 entries in table “DLFileEntryType”, but for other portal instances there are only four entries present in the table “DLFileEntryType.” A row in DLFileEntryType table with FileEntryTypeKey=BASIC-DOCUMENT is missing. This causes NullPointerException and prevents add button from appearing.
We have to add missing entry into DLFileEntryType table for all shards manually. Copy the row with FileEntryTypeKey=BASIC-DOCUMENT manually from default instance database to other shards' tables and refresh the page. You will see ADD button remains on the portlet and backend exception also disappears. Please note that you will need to generate and assign a new UUID to the ‘uuid_’ column when copying the row from default database table to shards' database tables.
For more implementation details or support you may contact us at [email protected].
For professional paid support, you may contact us at [email protected] .