Dead threads while connecting

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
kseen
Posts: 9
Joined: Thu 06 Oct 2011 10:16

Dead threads while connecting

Post by kseen » Fri 17 Feb 2012 03:54

While an app tries to connect to database server and retrieve some data, it sometimes raise an exception and it seems like it leaves dead threads when expcetion raised even when it's handled. So there are about 300 threads that getting service down.

Here is code invoked periodically on timer:

Code: Select all

Parallel.ForEach(dbs, pair =>
        {
            db l = pair.Value;

            if (String.IsNullOrEmpty(l.city))
                l.city = l.configCity;

            using (OracleConnection conn = new OracleConnection(l.connString))
            {
                try
                {                        
                    conn.Open();
                }
                catch (Exception exc)
                {
                    Console.WriteLine(String.Format("({0}, {1}): {2}{3}", l.connAlias, l.lid, exc.Message, Environment.NewLine));                        
                }

                try
                {
                    if ((conn != null) && (conn.State == ConnectionState.Open))
                    {        
                        // This method just call stored procedure and then set received data to 'l' object                    
                        if (!DbConnection.SetBadicData(conn, ref l))
                        {
                            Console.WriteLine(String.Format("Couldn't refresh basic data on ({0}, {1})", l.connAlias, l.id));
                        }                            

                        // This method also just call procedure and set received data to object
                        if (!DbConnection.SetExtendedData(conn, ref l))
                        {
                            Console.WriteLine(String.Format("Couldn't refresh advanced data on ({0}, {1})", l.connAlias, l.lid));
                        }
                    }
                }
                catch (Exception exc)
                {
                    Console.WriteLine(String.Format("({0}, {1}): {2}{3}", l.connAlias, l.lid, exc.Message, Environment.NewLine));
                }
            }

        });
Exceptions are:

1. Attempted to read or write protected memory. This is often an indication that other memory is corrupt
2. Internal exception in Oracle client
3. SEHException - External component has thrown an exception

How can I manage it guys? Does BeginConnect and then force breaking by EndConnect will help?

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Fri 17 Feb 2012 15:49

Similar problems were fixed in the previous versions of dotConnect for Oracle like "The bug with not freeing memory after command execution is fixed", "The bug with returning invalid connections to pool is fixed", etc. Please upgrade to the latest (6.70.302) version of dotConnect for Oracle.

If the problem persists with 6.70.302 as well, please create and send us a small complete test project with the corresponding DDL/DML script so that we can reproduce the issue in our environment.

kseen
Posts: 9
Joined: Thu 06 Oct 2011 10:16

Post by kseen » Wed 29 Feb 2012 09:55

We are using newest version. It's hard to model the same environment in test application.

Here is fresh error we got today that crashed our service:

Code: Select all

Unhandled Exception: System.AccessViolationException: Attempted to read or write
 protected memory. This is often an indication that other memory is corrupt.
   at OciDynamicType.nativeOCIHandleFree(IntPtr , Int32 )
   at OciDynamicType.OCIHandleFree(IntPtr , Int32 )
   at Devart.Data.Oracle.ae..ctor(Boolean A_0, Boolean A_1, OracleHome A_2)
   at Devart.Data.Oracle.ae.a(Boolean A_0, Boolean A_1, OracleHome A_2, Boolean
A_3)
   at Devart.Data.Oracle.a8..ctor(o A_0, a8 A_1)
   at Devart.Data.Oracle.bg.a(DbConnectionOptions A_0, Object A_1, DbConnectionB
ase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOpti
ons A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection
)
   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at AService.AServiceCaching.b__2(KeyValuePair`2 pair) in D:\inet
record\Server\AService\AServiceCaching.cs:line 78
   at System.Threading.Tasks.Parallel.c__DisplayClass32`2.b__30()
   at System.Threading.Tasks.Task.InnerInvoke()
   at System.Threading.Tasks.Task.InnerInvokeWithArg(Task childTask)
   at System.Threading.Tasks.Task.c__DisplayClass7.b__
6(Object )
   at System.Threading.Tasks.Task.ExecuteSelfReplicating(Task root)
   at System.Threading.Tasks.Task.Execute()
   at System.Threading.Tasks.Task.ExecutionContextCallback(Object obj)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
   at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
   at System.Threading.Tasks.ThreadPoolTaskScheduler.TryExecuteTaskInline(Task t
ask, Boolean taskWasPreviouslyQueued)
   at System.Threading.Tasks.TaskScheduler.TryRunInline(Task task, Boolean taskW
asPreviouslyQueued, Object threadStatics)
   at System.Threading.Tasks.Task.InternalRunSynchronously(TaskScheduler schedul
er)
   at System.Threading.Tasks.Task.RunSynchronously(TaskScheduler scheduler)
   at System.Threading.Tasks.Parallel.PartitionerForEachWorker[TSource,TLocal](P
artitioner`1 source, ParallelOptions parallelOptions, Action`1 simpleBody, Actio
n`2 bodyWithState, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal,
 Func`5 bodyWithEverything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEachWorker[TSource,TLocal](IEnumerable`
1 source, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState
, Action`3 bodyWithStateAndIndex, Func`4 bodyWithStateAndLocal, Func`5 bodyWithE
verything, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.ForEach[TSource](IEnumerable`1 source, Act
ion`1 body)
   at AService.AServiceCaching.refreshwork(Object obj) in D:\inetrecord\Server\A
Service\AServiceCaching.cs:line 45
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, C
ontextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart(Object obj)
ORA-24550: signal received: Unhandled exception: Code=c0000005 Flags=0

System.AccessViolationException: Attempted to read or write protected memory. Th
is is often an indication that other memory is corrupt.
   at OciDynamicType.nativeOCIHandleFree(IntPtr , Int32 )
   at OciDynamicType.OCIHandleFree(IntPtr , Int32 )
   at Devart.Data.Oracle.ae..ctor(Boolean A_0, Boolean A_1, OracleHome A_2)
   at Devart.Data.Oracle.ae.a(Boolean A_0, Boolean A_1, OracleHome A_2, Boolean
A_3)
   at Devart.Data.Oracle.a8..ctor(o A_0, a8 A_1)
   at Devart.Data.Oracle.bg.a(DbConnectionOptions A_0, Object A_1, DbConnectionB
ase A_2)
   at Devart.Common.DbConnectionFactory.a(DbConnectionPool A_0, DbConnectionOpti
ons A_1, DbConnectionBase A_2)
   at Devart.Common.DbConnectionPool.a(DbConnectionBase A_0)
   at Devart.Common.DbConnectionPool.GetObject(DbConnectionBase owningConnection
)
   at Devart.Common.DbConnectionFactory.b(DbConnectionBase A_0)
   at Devart.Common.DbConnectionClosed.Open(DbConnectionBase outerConnection)
   at Devart.Common.DbConnectionBase.Open()
   at Devart.Data.Oracle.OracleConnection.Open()
   at AService.AServ.GetDepartment(Key k) in D:\inetrecord\Server\AService\AServ
ice_Schedule.cs:line 308
   at SyncInvokeGetDepartment(Object , Object[] , Object[] )
   at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, O
bject[] inputs, Object[]& outputs)
   at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(Messag
eRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(Me
ssageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(M
essageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(Me
ssageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(M
essageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(Me
ssageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(Me
ssageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(M
essageRpc& rpc)
   at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(Me
ssageRpc& rpc)
   at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationConte
xtSet)
   at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(Reque
stContext request, Boolean cleanThread, OperationContext currentOperationContext
)
   at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
 request, OperationContext currentOperationContext)
   at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResul
t result)
   at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyn
cResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously, Except
ion exception)
   at System.ServiceModel.Channels.FramingDuplexSessionChannel.TryReceiveAsyncRe
sult.OnReceive(IAsyncResult result)
   at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
   at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously, Except
ion exception)
   at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.
OnReceiveComplete(Object state)
   at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(O
bject state)
   at System.ServiceModel.Channels.SocketConnection.FinishRead()
   at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean ha
veResult, Int32 error, Int32 bytesRead)
   at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32 err
or, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error,
UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
_kpedbg_dmp_stack()+269<-_kpeDbgCrash()+62<-_kpeDbgSignalHandler()+91<-_skgesig_
Win_UnhandledExceptionFilter()+140<-7C8361B4<-7C83929E<-00000000<-7C93C853<-7813
4D81<-A1006800<-00000001
Hope this helps.

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Wed 29 Feb 2012 15:51

1. It is recommended to restart program after exceptions like this one.
2. If possible, please send us a small test project with the corresponding DDL/DML script.
3. As a workaround, try using Direct Mode.

dhoenig
Posts: 16
Joined: Tue 20 Jul 2010 20:33

Re: Dead threads while connecting

Post by dhoenig » Sun 02 Sep 2012 18:44

kseen,
Did you get this issue resolved? We are experiencing the same exception. Thanks!

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Re: Dead threads while connecting

Post by Shalex » Thu 06 Sep 2012 12:28

dhoenig,
We have answered you at http://forums.devart.com/viewtopic.php?f=1&t=24551.

kseen
Posts: 9
Joined: Thu 06 Oct 2011 10:16

Re: Dead threads while connecting

Post by kseen » Wed 17 Apr 2013 09:06

dhoenig wrote:kseen,
Did you get this issue resolved? We are experiencing the same exception. Thanks!
No, still trying to solve it. And even doesn't getting any assistance from staff.

Shalex
Devart Team
Posts: 8088
Joined: Thu 14 Aug 2008 12:44

Re: Dead threads while connecting

Post by Shalex » Fri 19 Apr 2013 14:34

kseen,
Please refer to the discussion at http://forums.devart.com/viewtopic.php?f=1&t=24551 (3 pages): the bug was fixed starting from the 7.2.122 build of dotConnect for Oracle. We recommend you to install and check the latest (7.7.224) build. If you do not have access to the registered version, please download and evaluate the trial: http://www.devart.com/dotconnect/oracle/download.html.

Post Reply