I hope the following helps some folks in the future . . .
We recently upgraded from 6.5.4 to 8.5.1 and despite EVENTS4.NSF being upgraded from a clean R8.5.1 EVENTS4.NTF, had been suffering problems with missing/duplicate document errors along the lines of:
“Database events4.ntf in view (<$View Name>) contains X duplicate documents”.
DDM suggested running the console command “tell event clean <$View Name>” to resolve the problems and this did clean up most of our problems, but we were stuck with a 1 document duplicate in “($Messages)”. If we tried to run “tell event clean”, it terminated saying that an unexpected document had been found in the View, but each night the servers would still moan about a duplicate document in both EVENTS4.NSF & the .NTF.
Seeing as I did not want to manually locate the duplicate document I wrote an Agent to scan the “($Messages)” View and tell me where the duplicate was . . .
Create a new LotusScript Agent in EVENTS4.NTF, with a target of “None”. Then paste the code below into the Initialize event.
Now run the agent and it will report any duplicates in the Status Bar of your Notes client; then open EVENTS4.NTF, hold down Ctrl-Shift and from the menu select “View” \ “Goto” and open “($Messages)” . . . you should then be able to locate & delete the offending duplicate(s).
Note: DDM reports the code for the duplicate Message document e.g. “0x3308”, so you might try opening the “($Messages)” View and typing 0x33… to find the document, then find that it is not in the View. Be aware that the first column of the “($Messages)” View does not just list the contents of the “Value” field, it actually lists the “AddInName” field + the “Value” field e.g. “EVENT MONITOR0X3308”
(scroll down the View some and you’ll see what I mean).
Also note: You may also need to do the above on EVENTS4.NSF. I found that the deletion did not replicate to other instances of the .NTF & .NSF, so I had to manually delete the duplicate document from each replica instance of the database (but this may have been due to the activity of others resulting in deletion stubs already existing in the databases for the deleted document).
THE REST OF THIS POST IS THE AGENT CODE . . .
%REM
Agent Check For Duplicate 'Message' Definition Documents
Created June, 2010 by James Stuart.
Description:
PRE: Searches the View specified by 'Const lcstrLookupViewName' for duplicate documents.
Uses the contents of the 'Value' field as a unique key.
POST: Prints out the View index # & Unique Reference if a document is a duplicate.
%END REM
Dim lobjSession As New NotesSession
Dim lobjCurrentDatabase As NotesDatabase
Dim lobjLookupView As NotesView
Dim lobjCurrentDocument As NotesDocument
Dim lstrLastDocumentUniqueRef, lstrCurrentDocumentUniqueRef As String
Dim llngDocumentCount, llngDuplicateCount As Long
On Error GoTo ErrorHandler
Const lcstrLookupViewName = "($Messages)"
Set lobjCurrentDatabase = lobjSession.CurrentDatabase
Set lobjLookupView = lobjCurrentDatabase.GetView( lcstrLookupViewName )
Call lobjLookupView.Refresh
DoEvents
DoEvents
DoEvents
Set lobjCurrentDocument = lobjLookupView.GetFirstDocument()
lstrLastDocumentUniqueRef = "[Bogus Starting Value]"
lstrCurrentDocumentUniqueRef = ""
llngDuplicateCount = 0
While Not lobjCurrentDocument Is Nothing
llngDocumentCount = llngDocumentCount + 1
'@UpperCase(AddInName) + @UpperCase(Value):
lstrCurrentDocumentUniqueRef = UCase( lobjCurrentDocument.AddInName(0) & lobjCurrentDocument.Value(0) )
If lstrCurrentDocumentUniqueRef = lstrLastDocumentUniqueRef Then 'Duplicate found:
llngDuplicateCount = llngDuplicateCount + 1
Print "Duplicate Message document found at index " & Cstr( llngDocumentCount ) & " of View '" & lcstrLookupViewName & "'. 1st column value: " + lstrCurrentDocumentUniqueRef
End If 'lstrCurrentDocumentUniqueRef = lstrLastDocumentUniqueRef
lstrLastDocumentUniqueRef = lstrCurrentDocumentUniqueRef
Set lobjCurrentDocument = lobjLookupView.GetNextDocument( lobjCurrentDocument )
Wend 'Not lobjCurrentDocument Is Nothing
Print CStr( llngDocumentCount ) & " documents processed. " & CStr( llngDuplicateCount ) & " duplicates found."
GoTo TheEnd
ErrorHandler:
Print "ERROR: " & Err " at line " & Erl
End
TheEnd: