1

I have a multithread application with threadstatic sessions that does some job with files. It's using NH to consume from services and running on an oracle db, so far so good.

Every thread has a verbose log that uses stateless session to be more lightweight. BTW when some files are processed I can see that lots of cursors are managed in oracle for log session.

For instance log:

  • 324 SPC_LOG
  • 310 SPC_LOG
  • 121 SPC_LOG

and application itself:

  • 31 SPC_PRODUCTION_LINE_TEST
  • 27 SPC_PRODUCTION_LINE_TEST
  • 21 SPC_PRODUCTION_LINE_TEST

This drives me to run out of Oracle cursors ORA-01000.

Does somebody has an idea about what could cause this? Are cursors related to inserts or only updates? I guess that every thread at the end of it's life closes all sessions, regular and stateless.

FYI I'm writing log this way:

  • In Session factory

    public IStatelessSession GetUserStatelessContext(ConnectionStringSettings connection)
    {
        lock (Padlock)
        {
            string key = GetConnectionKey(connection);
    
            if (StatelessSessions == null)
            {
                StatelessSessions = new Dictionary<string, IStatelessSession>();
            }
    
            if (!StatelessSessions.ContainsKey(key))
            {
                StatelessSessions.Add(key, Factories[connection.ConnectionString].OpenStatelessSession());
            }
    
            return StatelessSessions[key];
        }
    }
    
  • And writing in log:

            using (ITransaction tx = this.LogProcessErrorRepository.BeginTransaction())
            {
                this.LogProcessErrorRepository.Add(log);
                if (log.Informations != null)
                {
                    foreach (AdditionalInformation info in log.Informations)
                    {
                        info.Text = this.OracleCLOBHack(info.Text);
    
                        this.AdditionalInformationRepository.Add(info);
                    }
                }
    
                tx.Commit();
            }
    
guillem
  • 2,768
  • 2
  • 30
  • 44
  • Guess: Try using ConcurrentDictionary and TryGetValue instead of Dictionary. http://msdn.microsoft.com/en-us/library/dd287191.aspx, http://stackoverflow.com/questions/1949131/net-dictionary-locking-vs-concurrentdictionary – Jamie Ide Nov 18 '12 at 13:53
  • @jamie-ide as far as I know is not a problem related to concurrent list, I'm using locks to avoid concurrence problems. Is more something related to Oracle driver, database or NH behavior. – guillem Nov 18 '12 at 15:42

1 Answers1

1

For the record the cause of the issue was the usage of the MS Oracle Client (System.Data.OracleClient) instead of the Oracle Data Provider (Oracle.DataAccess). In fluent is easy to confuse as the first one is OracleClientConfiguration and the ODP.Net OracleDataClientConfiguration as we were aware that the MS client is discontinued.

Right now database performance has increased in 400% and there is no cursor leakage at all. So from my point of view never use the MS client.

guillem
  • 2,768
  • 2
  • 30
  • 44