You have noticed that the system database has become unusually large and maintenance fails with the following error message:
Stored procedure: [dbo].[SpDeleteOlderRecords] Failed; Inner Message: The transaction log for database 'SystemDB' is full due to 'ACTIVE_TRANSACTION'
BarTender System Database
In Administration Console under "Administrative Tasks > View Database Size..." make sure that the transaction log file size is small.
Normally, the SQL Server transactional log file (.LDF) for the BarTender System Database grows during database maintenance, but should shrink to its original size after maintenance has finished. However, this does not always occur and the LDF file starts growing too much.
The customer's Transaction Log is not big enough to handle all of the transaction information for the maintenance operations. The maintenance operations consists of three steps:
- Delete older records
- Reorganize or rebuild the indexes (may be requiring a lot of Transaction Log space)
It is recommended to allocate more space for the Transaction Log. Additionally, the Recovery Model should be "Simple", as it uses much less Transaction Log space.
- In SQL Server Management studio, verify what the Maxsize for your Transaction log file is by right clicking your System Database>Properties>Files.
- In the system database properties verify that the recovery model for your System Database is set to Simpleby right clicking your System Database>Properties>Options>Recovery Model
- Run the "manual unlock" procedure to unlock maintenance, if necessary (see below).
- Start the Administration Console to run maintenance.
- Once maintenance is complete, take a look at the Transaction Log file to see how much it's grown.
- Go back into database properties and set the size limit of the file to be somewhere in the magnitude of the size of the file on disk, instead of unlimited.
"Manual unlock" procedure
- Stop the "BarTender System Service" Windows Service.
- With SQL Server Management Studio's Object Explorer (typically left-hand side pane), expand your database, then visit the "Programmability" folder, choose the "Stored Procedures" folder.
- Run the below procedure (if 0 rows are affected, run the call once more):
exec SpDsUnlockMaintenance 0
- Browse to the "SpDeleteRecords" procedure.
- Right-click on "SpDeleteRecords" and choose "Script stored procedure as" > "ALTER to" > "New query editor window"
- At the new Editor, remove the "WITH EXECUTE AS 'dbo'" from the "ALTER PROC" line, so that it appears as:
ALTER PROC [dbo].[SpDeleteRecords](@pastUtcTicks bigint, @categories nvarchar(1024))
- Now run this query (typically with F5) to alter the Stored Procedure.
- Restart the "BarTender System Service" Windows Service.
Shrinking the log size
You should execute the following query to SHRINK the current database's log file size after an operation that creates a large amount of unused space, such as a truncate table or a drop table operation.(In the below script, you will need to replace [Database name] with the name of your database)
-- Set the system database recovery model to SIMPLE, and then runs the DBCC SHRINKFILE operation over the Transaction Log.
ALTER DATABASE "[Database name]" SET RECOVERY SIMPLE
DBCC SHRINKFILE ([Database name]_Log, 1);