Program creating infinite SQL processes in SQL Server Management Studio activity monitor

23 views
Skip to first unread message

Renee Jylkka

unread,
Jun 17, 2018, 4:16:42 PM6/17/18
to golang-sql
I'm running MS SQL server express version 2017, Go version 1.10.2, and the current github.com/denisenkom/go-mssqldb.  My program is a web app which runs as a service.  It creates the connection in the main process:

fldb, err = sql.Open("mssql", connectionString)
    if err != nil {
        log.Println("Error opening the MSSQL database connection: " + err.Error())
        return err
    }
    defer fldb.Close()



Then I use http.HandleFunc to serve my pages. For each page, it sends it to a function to a function based on the page name to pull values from the database. A code snippet from one of my page functions:

        rows, err := fldb.Query(queryString)
        
if err != nil {
             log.Println("Error running SQL query (finding customers): " + queryString + " : " + err.Error())
            return err
        }
         defer rows.Close()       
        /* For each row */
        for i := 0; i < 20; i++ {
        if !rows.Next() {

(then I scan and deal with the data from the twenty rows before returning)

It all works, but I must be doing something wrong because one of my coworkers noticed that we had this enormous number of processes showing in the activity monitor of the SQL Server Management Studio.  Further investigation shows that it creates a new process for every page, and never shuts it down.  What am I missing?

Thanks in advance,
Renee

Daniel Theophanes

unread,
Jun 18, 2018, 9:54:03 AM6/18/18
to Renee Jylkka, golang-sql
Are you setting the max number of connections on the pool? 

--
You received this message because you are subscribed to the Google Groups "golang-sql" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-sql+...@googlegroups.com.
To post to this group, send email to golan...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-sql/4da04f9d-735f-6640-4813-b2eb7ff814db%40ormandy.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages