ORA-01000: maximum open cursors exceeded golang

Asked

Viewed 179 times

0

I have a service that runs a stack. For this, it performs the reading of this stack through a query in Oracle. Turns out, after hours of execution, I get the message:

ORA-01000: maximum open cursors exceeded

I wonder what’s going on. I have a global variable that opens the connection and when I run a query I always check your connection and copy it to the local variable.

In Rows.Next (), from what I read, when it checks for no more lines, it closes the cursor, so I could not have accumulated so many open cursors to exceed the limit.

Connection to the bank:

type GERENCIACON struct {
DataBase *sql.DB
}

func (gc *GERENCIACON) F_FECHAR_CONEXAO() {
gc.DataBase.Close()
}

func (gc *GERENCIACON) F_ABRIR_CONEXAO()  { 
if gc.DataBase == nil || gc.DataBase.Ping() != nil {    
    gc.DataBase, _ = sql.Open("goracle", "X/[email protected]:1521/orcl")
}
}

var VGGerenciaConexao GERENCIACON

Structure for consultation:

type GERENCIACONSULTA struct {
DataBase *sql.DB
Rows *sql.Rows
}

func (gc *GERENCIACONSULTA) F_EXECUTA_CONSULTA(pSql string) {
VGGerenciaConexao.F_ABRIR_CONEXAO()
gc.DataBase = VGGerenciaConexao.DataBase
gc.Rows, _ = gc.DataBase.Query(pSql)
}

Battery Execution Service

 var vGerenciaConsulta CertanoLabsPackage.GERENCIACONSULTA
 var vSQL string

  for {
    vSQL = "select * from stack "   

   vGerenciaConsulta.F_EXECUTA_CONSULTA(vSQL)

      for vGerenciaConsulta.Rows.Next() {
      ...
     }

time.Sleep(time.Minute)
 }

Would anyone know to tell me what might be going on?

  • Man, let me ask you.. How many records is this processing?

  • You can post this Serviço de Execução complete? It seems to me that you are creating a new instance of GERENCIACONSULTA each time you execute this code, which in turn opens a new connection each time you invoke F_EXECUTA_CONSULTA

  • The problem with open cursors was not the query, I discovered that it was not closing the DML operations. I checked at the bank and had over 5000 cursors open. But it worked guys. Thanks for the help.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.