Skip to content

CLI0129E: An attempt to allocate a handle failed because there are no more handles to allocate #145

@yyt030

Description

@yyt030
  • os Version: win7
  • cli-driver Version: DB2 v11.1.4040.491
  • Db2 Server Version: DB2 v11.1.4040.491
  • go Version: go version go1.17.1 windows/amd64
go env Output:
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.1
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build1348026963=/tmp/go-build -gno-record-gcc-switches

Steps to Reproduce:

  1. go run main.go . source code is this:
package main

import (
	"database/sql"
	"flag"
	"log"

	_ "github.com/alexbrainman/odbc"
	_ "github.com/ibmdb/go_ibm_db"
)

var dbType string

func init() {
	flag.StringVar(&dbType, "o", "odbc", "dbType")

	flag.Parse()
}

func main() {
	var connStr string
	if dbType == "odbc" {
		connStr = "dsn=localdb;UID=db2admin;PWD=db2admin"
	} else {
		connStr = "HOSTNAME=localhost;PORT=50000;DATABASE=go;UID=db2admin;PWD=db2admin"
	}
	log.Printf(">>> %s", dbType)

	db, err := sql.Open(dbType, connStr) // odbc or go_ibm_db
	if err != nil {
		panic(err)
	}
	defer db.Close()

	if err := db.Ping(); err != nil {
		panic(err)
	}

	for i := 0; i < 10000; i++ {
		func() {
			tx, err := db.Begin()
			if err != nil {
				panic(err)
			}
			defer tx.Rollback()

			rows, err := tx.Query("select id, value, name from administrator.test")
			if err != nil {
				panic(err)
			}
			defer rows.Close()

			for rows.Next() {
				var (
					v, name string
					id      int
				)
				if err := rows.Scan(&id, &v, &name); err != nil {
					panic(err)
				}
			}
		}()
	}
}

the output is :

C:\workspaces\demo\db2demo>go run main.go -o go_ibm_db
2021/10/18 21:55:12 >>> go_ibm_db
panic: SQLExecDirectW: {HY014} [IBM][CLI Driver] CLI0129E  An attempt to allocate a handle failed because there are no more handles to allocate. SQLSTATE=HY014

goroutine 1 [running]:
...

C:\workspaces\demo\db2demo>go run main.go -o odbc
2021/10/18 22:02:39 >>> odbc

Is that the driver lib(go_ibm_db) NOT release db2 handle??????

@akhilravuri1

pls help me.

thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions