Question

I've recently deleted 120,000 Users from my Liferay database using an automated script. Before that however, I manually deleted 2 Users from the database using DELETE FROM User_ WHERE userId=1234567 - just to see what might happen with any associations that User might have had.

The User was deleted, but all other table rows holding that userId (1234567) remained. Fine.

So now I'm at a point where I'd like to reindex all search indexes to get a current list of users, but LR throws an exception:

08:07:41,922 ERROR [http-bio-20110-exec-290][LuceneIndexer:136] Error encountere
d while reindexing
com.liferay.portal.kernel.search.SearchException: com.liferay.portal.NoSuchUserE
xception: No User exists with the key {contactId=1234568}
       at com.liferay.portal.kernel.search.BaseIndexer.getDocument(BaseIndexer.j
ava:179)
       at com.liferay.portlet.usersadmin.util.ContactIndexer$1.performAction(Con
tactIndexer.java:203)
  at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActions
InSingleInterval(BaseActionableDynamicQuery.java:309)
     at com.liferay.portal.kernel.dao.orm.BaseActionableDynamicQuery.performActi

This contactId seems to be a single digit higher than the userId for any user created (I could be wrong about that)

So my question is, how can I fix this problem so I can perform the reindex?

Liferay EE 6.2 Tomcat 7.0.33 SQL Server

Was it helpful?

Solution

I found out the contactId for my manually deleted user was still in the Contact_ Table. I deleted him from the table and can now perform the reindex. I can now see all the user & user groups after reindexing.

From LR:

rule #1 with using Liferay - The database is not yours, you should never be in it and you should never be issuing sql against it.

The Liferay API is the only way to modify data. Period.

The Liferay API supports user deletion. Had you used the Liferay API, the users would have been deleted and your indexes, etc., would have been fine.

Okay, I know that's going to come across as a little aggressive or something, but it's important. The whole Liferay system depends upon it's data, so any time you tweak the data manually it potentially breaks the system. If you dig through the actual process that the Liferay API does for a user deletion, you'd see that the "delete from user_ where ..." is just a small part.

I always tell people new to Liferay to just forget that the database exists. It's definitely their database, not yours, and it's not to be messed with.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top