on 02-16-2006 9:14 AM
I have a .NET program that opens 2 threads to call SAP, with a connection pool of 1 concurrent connection (for testing purposes). When i call the program, I get the following trace:
2006-02-16 15:39:29Z Trace file opened.
2006-02-16 15:39:29Z Allowed to fetch new.
2006-02-16 15:39:29Z Getting new.
2006-02-16 15:39:29Z Allowed to fetch new.
2006-02-16 15:39:29Z Getting new.
2006-02-16 15:39:29Z AllocReservation: 0
2006-02-16 15:39:29Z AllocReservation: 1
2006-02-16 15:39:30Z Call method Zppeh_Inspoper_Getdetail
2006-02-16 15:39:49Z Releasing: 1
2006-02-16 15:39:49Z Call method Zppeh_Inspoper_Getdetail
I have set my connection pool string as follows:
MaxOpenConnections="1", MaxCapacity="0", MaxIdleTime="15",
CleanupInterval="5"
It seems that the second thread gets blocked, but it doesn't get released until the .NET connector terminates the connection (due to MaxIdleTime + CleanupInterval), rather than when the first thread returns the connection. Notice the 19 second difference between the call methods.
I am using .NET Connector v2.0.1 with Connection.GetConnection and Connection.Dispose.
Am I doing something wrong here?
Global.BotNptSap is a string constant. That is, "ASHOST=erpqa SYSNR=00 CLIENT=010 USER=ABC PASSWD=***"
FYI, we are having issues with IIS 6.0 crashing when many users are accessing our web application and we are thinking that it might have to do with something wrong with how we are using the .NET Connector code. So we wrote the above program and found this issue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Pikad,
I found the bug in NCo: as GetConnectionFromPool doesn't open the connection, it can happen that more connection would be created than MaxOpenConnection allows. The additional connection would then block until a connection really closes.
You can work arround the problem with the follwing change: replace the line
qmProxy.Connection = Connection.GetConnectionFromPool(Global.BotNptSap)
with
SyncLock GetType(SAP.Connector.Connection)
qmProxy.Connection = Connection.GetConnectionFromPool(Global.BotNptSap)
qmProxy.Connection.Open()
End SyncLock
I'm not yet sure how I can fix the problem in general. Automatically opening the connection in GetConnectionFromPool would be an incompatible change.
Let's see...
I tried monitoring using SM50 and the thread invoking the RFC occurs as I've explained (one is invoked right away and another is invoked 20 secs afterwards).
My code block calling SAP is:
Try
qmProxy.Connection = Connection.GetConnectionFromPool(Global.BotNptSap)
qmProxy.Zppeh_Inspoper_Getdetail(...)
If retcode.Type <> "E" Then ' Suceed
Trace.Write("OK!")
End If
Catch ex As Exception
Trace.Write(ex.Message)
Finally
Connection.ReturnConnection(qmProxy.Connection)
qmProxy.Connection = Nothing
End Try
I've tried some further investigation and it might have to do with the code creating the threads, where CallRepeat is the function that contains the above code:
Try
For i As Integer = 1 To 2
Dim Thread1 As New System.Threading.Thread(AddressOf CallRepeat)
Thread1.Start()
'' If I include the 3 lines below, everything is ok
'If i = 1 Then
' Thread1.Join()
'End If
Next
Catch ex As Exception
_log.Error(ex.Message)
Finally
End Try
If I include the 3 lines commented out, then everything is ok...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In the R/3 system go to the Transaction SM50 and monitor how the thread's invoking the RFC behave.
(i.e) Here you can check if the RFC is executed one by one or is getting executed simultaneously or if any RFC execution in getting blocked.
I think this will help you to figure out how the 2 threads impact the RFC call made.
Hope this helps you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you please post your test code? Maybe you forgot the ReturnConnection() after the RFC call?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.