Intermittent OpenByRelicaID failure

I have an agent which uses db.OpenByReplicaID within a loop to open another database and transfer a file to a document in the newly-opened database. Approximately 50% of the time the OpenByReplicaID fails even though the Replica ID is correct and and the same code has worked for a previous documents in the loop which were being transferred to the same target database.

When I run the agent under the debugger I get the same intermittent results. I run the agent once and the OPenByReplicaID fails and then I run it a second time against the same document ( and therefore the same replica ID ) and it works. Each time I verified the replica ID field was correct before executing the OpenByReplicaID method.

The original database is on a 7.0.1 server whereas the target database which the agent has problems opening is still on a 6.5 server.

A possible cause for this intermittent failure is that the target database I am trying to open is quite large - approx 150,000 documents and 8 gigabytes.

Has anyone out there worked with a database of this size (or larger) and seen this type of problem?

Any other suggestions as to the probable cause?

Thanks

Trevor

Subject: Intermittent OpenByRelicaID failure

please post your code

are you getting any error messages? If so, what is the EXACT error msg?

Subject: RE: Intermittent OpenByRelicaID failure

The code is:=========================================

Sub GetTargetDoc(strDBID As String, strDocID As String, dbTarget As NotesDatabase, _

docTarget As NotesDocument, strImageField As String, strTextField As String, _

bNotifyFlag As Boolean, intRC As Integer)

’ Given DB id and document id, get handle to target database document along with

’ names of target fields

On Error Goto ErrorRoutine



Dim view As NotesView

Dim doc As NotesDocument

Dim item As Variant



' Get handle to target database

Set view = db.GetView("(DatabaseLookup)")

Set doc = view.GetDocumentByKey(strDBID)	

If doc Is Nothing Then

	intRC = ERRCD_MISSING_TARGET_DB_DOC

	Exit Sub

End If



Set dbTarget = New NotesDatabase("", "")

Call dbTarget.OpenByReplicaID(doc.Server(0), strDBID)

If Not dbTarget.IsOpen Then

	Call aLog.LogAction("Unable to open database " + strDBID + " on " + doc.Server(0))

	intRC = ERRCD_CANNOT_OPEN_TARGET_DB

	Exit Sub				

End If



' Get handle to target document

On Error ERRCD_MISSING_UNID Goto BadUNID

Set docTarget = dbTarget.GetDocumentByUNID(strDocID)

If docTarget Is Nothing Then

	intRC = ERRCD_CANNOT_OPEN_TARGET_DOC

	Exit Sub				

End If



' Get names of target fields

Call LookupFieldNames(docTarget.Form(0), strDBID, strImageField, strTextField, _ 

bNotifyFlag, intRC)



Exit Sub

BadUNID:

Set docTarget = Nothing

intRC = ERRCD_CANNOT_OPEN_TARGET_DOC

Exit Sub				

ErrorRoutine:

Error Err, Error$ & Chr$(10) & " in procedure " & Getthreadinfo(1) & ", line " & Cstr(Erl)

RoutineExit:

End Sub

=========================================

There is no error message generated. The call to OpenByReplicaID sometimes opens the database and sometimes doesn’t. dbTarget.IsOpen returns False and the routine exits with my own error code set.

As I said before, I have run this code using the debugger and verified the value for strDBID is a valid replica ID. Sometimes it opens the DB and sometimes it does not for the same value in strDBID.

Because of this I think the problem is “environmental” and not a simple coding error. This code has been running for over a year without a problem. The difference is now the target database is on a v7.0 server and has grown quite large. Hence the question about large databases.

Thanks

Trevor