BSA: Another Database cleanup already in progress. Please wait till first Database cleanup finishes.

Version 1
    Share This:

    This document contains official content from the BMC Software Knowledge Base. It is automatically updated when the knowledge article is modified.


    PRODUCT:

    TrueSight Server Automation Suite


    APPLIES TO:

    BSA/TSSA 8.9.X



    PROBLEM:

    Running the BSA cleanupHistoricalData commands or the cleanupDatabase command returns the following messages for some of the historical data procedures:

    Wed Jul 18 18:19:03 CST 2018] Another cleanup already in progress. Quitting... 
    [Wed Jul 18 18 CST 2018] Another Database cleanup already in progress. Please wait till first Database cleanup finishes.

    In BSA 8.9.03 the message is:

    Command execution failed. com.bladelogic.om.infra.mfw.BlException: Another historical data cleanup is already in progress. Please check the run_id(s) in dbm_run table. RunId 2859 started for PatchResult at 2018-07-14 08:39:17 and status is In Progress.
    Exit Code 1



     


    CAUSE:

    A previous run of the cleanup is marked as running.


    SOLUTION:

    The first thing to check/confirm is that another BSA DB Cleanup Job is not actually running. 

    If another BSA DB Cleanup Job is running, that must be allowed to complete before the next cleanup job is running. If running via a Batch Job, check the member jobs to make sure they are set to run sequentially and not in parallel.

    If no other BSA DB Cleanup Job is running, this error usually occurs after a previous run did not complete cleanly. This can happen if there is a sudden DB or Appserver outage in the middle of a DB Cleanup run.

    To troubleshoot, run the following queries on the Bladelogic DB/Schema. Open a case with BMC Customer Support and provide the results.
    A SQL remediation can be provided to clear the remnants of the stuck run.


    1) ORACLE DB:

    --Query1
    select * from system_property where name like 'OnlineDBMaintenanceInProgress';

    --Query2
    select * from system_property where name like 'OfflineDBMaintenanceInProgress';

    --Query3
    select greatest( (select count(*)
                        from dbm_run
                       where end_time is null
                         and upper(run_type) = 'ONLINE'
                         and run_id != (select MAX(run_id) from dbm_run_log)),
                     (select count(*)
                        from delete_tasks_statistics
                       where end_dtm is null)
                   ) is_online_clnup_running
      from dual;

    --Query4
    select greatest( (select count(*)
                        from dbm_run
                       where end_time is null
                         and upper(run_type) = 'OFFLINE'
                         and run_id != (select MAX(run_id) from dbm_run_log)),
                     (select count(*)
                        from delete_tasks_statistics
                       where end_dtm is null)
                   ) is_offline_clnup_running
      from dual;
      
      --Query5
      select *
      from dbm_run
     where end_time is null
       and upper(run_type) = 'ONLINE';
       
    --Query6
    select *
      from dbm_run
     where end_time is null
       and upper(run_type) = 'OFFLINE';
      
    --Query7
    select *
      from delete_tasks_statistics 
     where end_dtm is null;



    2) SQL Server DB:

    --Query1
    select * from system_property where name like 'OnlineDBMaintenanceInProgress';
    GO
     
    --Query2
    select * from system_property where name like 'OfflineDBMaintenanceInProgress';
    GO

    --Query3
    create function [dbo].[greatest] (@str1 nvarchar(max),@str2 nvarchar(max))
    RETURNS nvarchar(max)
    BEGIN
     
       DECLARE @retVal nvarchar(max);
     
       set @retVal = (select case when @str1<=@str2 then @str2 end as retVal)
     
       RETURN @retVal;
    END;
    GO
     
    --Query4
    select dbo.greatest( (select count(*)
                        from dbm_run
                       where end_time is null
                         and upper(run_type) = 'ONLINE'
                         and run_id != (select MAX(run_id) from dbm_run_log)),
                     (select count(*)
                        from delete_tasks_statistics
                       where end_dtm is null)
                   ) is_online_clnup_running;
    GO
     
    --Query5
    select dbo.greatest( (select count(*)
                        from dbm_run
                       where end_time is null
                         and upper(run_type) = 'OFFLINE'
                         and run_id != (select MAX(run_id) from dbm_run_log)),
                     (select count(*)
                        from delete_tasks_statistics
                       where end_dtm is null)
                   ) is_offline_clnup_running;
      GO
     
    --Query6
     select *
      from dbm_run
    where end_time is null
       and upper(run_type) = 'ONLINE';
    GO
     
    --Query7
    select *
      from dbm_run
    where end_time is null
       and upper(run_type) = 'OFFLINE';
    GO
      
    --Query8
    select *
      from delete_tasks_statistics
     where end_dtm is null;
    GO

    --Query9 
    DROP FUNCTION dbo.greatest
    GO
     


    Article Number:

    000116501


    Article Type:

    Solutions to a Product Problem



      Looking for additional information?    Search BMC Support  or  Browse Knowledge Articles