Sometimes the Compact task will fail to complete due to a problem with the structure of a database. This can usually be fixed by manually running a Fixup command, at the Admin Console, which will correct the problem with the database corruption.

This is a manual process which will need to be carried out by the Domino Administrator. To prevent the admin having to do this I have written the Lotusscript agent below which can be put into a database, on a server in the Domain, to execute automatically.

  1. Create a new blank database on your Domino server.
  2. Create a new agent from the Designer.
  3. Set the agent type as Lotusscript.
  4. Copy and paste the Lotusscript below into the code window.

    %REM
        Agent Auto Fixup
        Created Aug 2009 by Paul Farris
        Description: Agent to automatically run a remote fixup command.
    %END REM
    Option Public
    Option Declare

    Sub Initialize()
        Dim session As New NotesSession
        Dim db As NotesDatabase
        Dim doc,doc2 As NotesDocument
        Dim item As  NotesItem
        Dim unProcessedDocuments As NotesDocumentCollection
        Dim dc As NotesDocumentCollection
        Dim contents,substring,servername,consolereturn As String
        Dim string_start,string_end As Integer
        Dim result As Variant
        Dim rti As NotesRichTextItem
        Dim found As integer
        Print "Running Auto fixup"
        Set db = session.CurrentDatabase
        Set unProcessedDocuments = db.UnprocessedDocuments
        Set doc = unProcessedDocuments.GetFirstDocument()
        If Not(doc Is Nothing) Then
            found=0
            Print unProcessedDocuments.Count & " new documents found"
            Set doc2 = New NotesDocument( db )
            Set rti = doc2.CreateRichTextItem("Body")
            While Not(doc Is Nothing)
                If doc.Hasitem("Body") And doc.HasItem("EventText") And doc.HasItem("ServerName") Then
                    Set item = doc.GetFirstItem("Body")
                    contents = item.Text
                    string_start = InStr(1,contents, |"|)+1
                    string_End = InStr(string_start,contents, |"|)
                    substring = Mid$(contents, string_start, string_end-string_start)
                    If string_End>0 Then
                        Print "Found: " & substring
                        servername = doc.ServerName(0)
                        consolereturn = session.SendConsoleCommand(servername, substring)
                        Print consolereturn
                        Call rti.AddNewLine(1)
                        Call rti.AppendText("Sending remote command to " & servername & " for " & StrRightBack(substring," "))
                        found=found+1       
                    Else
                        Print "Auto Fixup Error - String not found"
                    End If
                End If
                Call session.UpdateProcessedDoc(doc)
                Set doc = unprocessedDocuments.GetNextDocument(doc)
            Wend
            If found>0 then
                doc2.Subject ="Auto Fixup summary"
                doc2.SendTo = "Notes Administrator/Org"
                doc2.Form = "Memo"
                Call doc2.Send(False)
            End if
        Else
            Print "Auto Fixup: No documents found"
        End If
    End Sub

  5. Set the agent Trigger to “On Event”.
  6. Select “After Document are created or modified”.
  7. Set “Runtime Security Level” to “Allow Restricted Operations”.
  8. Sign the agent with an ID which can run restricted operations on the server.
  9. Create a mail-in database entry, in the Domain address book, pointing to this database.
  10. Configure DDM (Domino Domain Monitoring) with an event handler, when the message is “Database is corrupt -- Cannot allocate space”, to send an email to a mail-in database setup previously.

Now whenever a compact fails it will send the email alert, to the database, which will trigger the execution of the agent. The remote commend is sent to the server and an email generated to notify the admin. One less job for a busy admin to do.