Recently visited doesn't load for particular user after an upgrade
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Problem
Recently visited page keeps spinning without loading anything.
The following appears in the atlassian-confluence.log
when clicking on Recently Visited
[http-nio-8090-exec-25] [service.content.factory.DefaultContentMetadataFactory] makeMetadata API metadata provider module threw an exception attempting to expand metadata. Class : com.atlassian.confluence.plugins.recentlyviewed.cql.metadata.CurrentUserMetadataProvider provides properties [currentuser]. Exception java.lang.IllegalArgumentException: duplicate key: 93946027
Diagnosis
Run the following database query to make sure there's no duplicated record in the database :
SELECT * FROM AO_92296B_AORECENTLY_VIEWED WHERE USER_KEY = (SELECT USER_KEY FROM user_mapping where lower_username = '<affected-user>') and CONTENT_ID=<duplicated key shown in the logs>;
Insert affected user's user_key
and duplicated key that shown in the logs into the query (example: "93946027" based on the sample error message above). If the query return more than one query, then you may proceed with resolution.
Cause
The reason that causes Confluence to have duplicated row of records in the table AO_92296B_AORECENTLY_VIEWED
remains unknown.
The duplicated row of records in the mentioned table will not affect the Recently visited
page in version 5.8.x, however it will affect in the version 5.9.x.
Resolution
Run the following query to remove duplicated records in the table.
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
Always back up your data before performing any modifications to the database. If possible, test any alter, insert, update, or delete SQL commands on a staging server first.
DELETE FROM AO_92296B_AORECENTLY_VIEWED WHERE ID='<ID shown in query output above>';