How to clean up task queue for scheduled app tasks in CCDB
search cancel

How to clean up task queue for scheduled app tasks in CCDB

book

Article ID: 298152

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

If you use the Scheduler to schedule tasks for an app, and those tasks are frequent, such as every minute, the number of Completed tasks can build up to a large number (<45,000). This task queue can impact performance of cf API operations, such as cf delete <app> or cf push. How can we purge the task queue automatically?

Environment

Product Version: 3.0

Resolution

Completed tasks are automatically purged from the CCDB; the frequency of the purge is configurable in the TAS tile "Cloud Controller" tab:

cutoff_age_in_days setting
By setting this value lower than the default of 31 days, the maximum size of the tasks queue will be proportionally smaller. To change the setting, enter the desired value in the field (pictured above), Save the change, and Apply Changes to TAS tile.
 

To connect to the CCDB:

https://community.pivotal.io/s/article/How-to-Connect-to-the-Pivotal-Application-Service-Internal-MySQL-database?language=en_US

To see the number of tasks in the CCDB task queue, you can execute the following query:
 

SELECT app_guid, COUNT(*) FROM tasks GROUP BY app_guid ORDER BY 2


The cloud_controller source code specifies the default behavior:
https://github.com/cloudfoundry/cloud_controller_ng/blob/8bb3f137f493aeb951962b37f62a2cc115d024a8/app/jobs/runtime/prune_completed_tasks.rb#L17

The variable cutoff_age_in_days comes from clock_global cloud_controller_ng.yml
https://github.com/cloudfoundry/capi-release/blob/d1e89befd672046ef5f2f208478a28d948ccc7b6/jobs/cloud_controller_clock/spec#L109