Activity Stream Gadget causing high memory/CPU consumption

Type atlassian
Modified 2019-08-20T00:22:31


+Problem Definition+ Activity Stream Gadget causing high memory/CPU consumption when there is 1 million+ of records in the AO_563AEE_ACTIVITY_ENTITY table.

In this particular case, found that majority of these records are from 3rd party plugins (Insight). However, do note that this can happen to any plugins so long you have large amount of data in the mentioned table.

And also, even after we have filtered off everything using the Global Filter, accessing the Filter configuration still does a check on the table which causes the high memory/CPU.

+Suggested Solution+ # Current design, once the Activity Stream Gadget is added it will load all records before you can access to the filter configuration and configure the necessary filter. Propose to first show the filter configuration screen before loading the data, this will allow user to configure the data returned. # And also, once filtered off everything accessing the filter configuration will still cause high CPU/memory consumption as it seems that below SQL is triggered upon clicking on filter configuration. Propose to review the code if is necessary to trigger the SQL query while loading the filter configuration, {code:java} 2017-08-16 20:25:38,209 StreamsCompletionService::thread-36 DEBUG xxxxxx 1225x624x1 15efyoj 0:0:0:0:0:0:0:1 /rest/activity-stream/1.0/config [] SELECT PUBLISHED,URL,TITLE,GENERATOR_ID,USERNAME,ISSUE_KEY,GENERATOR_DISPLAY_NAME,CONTENT,ID,ACTIVITY_ID,PROJECT_KEY,POSTER,VERB FROM AO_563AEE_ACTIVITY_ENTITY {code}  

+Why this is important+ With current design, this will cause high CPU/memory consumption which will halt the system eventually. A restart would be require to fix the slowness.

+Workaround+ Review the records in the AO_563AEE_ACTIVITY_ENTITY table. Delete old or unwanted data. You can run the following queries to check the records and delete accordingly. # Check how many records and the respective plugins. {code:java} SELECT GENERATOR_DISPLAY_NAME as Plugin, count(ACTIVITY_ID) as ID FROM AO_563AEE_ACTIVITY_ENTITY group by Plugin{code}

# Check number of records and group by year {code:java} SELECT year(published) as year, count(ACTIVITY_ID) as ID FROM AO_563AEE_ACTIVITY_ENTITY group by year {code}