Home > front end >  Golang - many in use connections
Golang - many in use connections

Time:03-26

#golang #oracle

Im trying to understand how the Max connection works. Basically I have this db configuration:

params.MinSessions = 5
params.MaxSessions = 6
params.SessionTimeout = 0
params.WaitTimeout = 5 * time.Second
params.SessionIncrement = 0
params.ConnClass = "GOLANGPOOL"

// Connect!
result, err := sql.Open("godror", params.StringWithPassword())

However I can see 242 connections using sql.DB.Stats:

DB Established Open Conn (use   idle): 242
DB Idle Conn: 0
DB In Use Conn: 242
DB Max Idle Closed: 766
DB Max Idle Time Closed: 0
DB Max Lifetime Closed: 0
DB Max Open Conn: 0
DB Wait Count: 0
DB Wait Duration (sec): 0

How is it possible? The limit shouldn't be 6?

Thanks

CodePudding user response:

In Oracle connections and sessions are different concepts.

A connection is a network connection to the DB, while a session is an encapsulation of a user's interaction with the DB...

refering to this book, and Relation between Oracle session and connection pool.

CodePudding user response:

DB In Use Conn: 242 DB Max Idle Closed: 766

The sum is almost 1000, like the value of this default

poolMaxSessions=1000

I think you don’t have 242 simultaneous connections in use. You have a pull of connections and the database will limit the number of simultaneous sessions.

You should check how the sql package handles it (it is open source!) and how the specific driver handles it (also open source!) and if necessary open an issue on the driver project

https://github.com/godror/godror

  • Related