Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Improve locking DB operations
From time to time I can see this issue in the server log:
2024-06-07 01:24:14.994 ERROR [liferay/async_service-1491][BatchingBatch:134] HHH000315: Exception executing batch [java.sql.BatchUpdateException: Batch entry 0 insert into Lock_ (mvccVersion, uuid_, companyId, userId, userName, createDate, className, key_, owner, inheritable, expirationDate, lockId) values (0, 'df69853e-e63a-cf96-f7cc-0c3c5a8ad12c', 10131, 0, NULL, '2024-06-07 01:24:14.978+00', 'com.liferay.social.kernel.model.SocialActivityCounter', '10719#10046#12904074#user.activities#1', '10719#10046#12904074#user.activities#1', 'FALSE', NULL, 103982867) was aborted: ERROR: duplicate key value violates unique constraint "ix_228562ad"
Detail: Key (classname, key_)=(com.liferay.social.kernel.model.SocialActivityCounter, 10719#10046#12904074#user.activities#1) already exists.
We have enabled measuring social activities. Social Activity counters in LR are created asynchronously by multiple threads so the core method uses the lock service to guard against multiple threads trying to insert the same counter (a quote from SocialActivityCounterLocalServiceImpl.java).
However, the current implementation seems to be suboptimal:
SocialActivityCounter activityCounter = this.fetchLatestActivityCounter(...);
if (activityCounter == null) {
activityCounter = this.lockProtectedAddActivityCounter(...);
}
It prevents creating duplicate counters, but it doesn't prevent creating duplicate locks. The related stack traces are quite huge and I'd like to eliminate it.
Feature Request Created: https://liferay.atlassian.net/browse/LPD-28272
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™