Search code examples
servicestackormlite-servicestack

Servicestack ORM db.Close() does not terminate the connection process


I have a code which demonstrates simple mysql database connection with ServiceStack ORM

var dbFactory = new OrmLiteConnectionFactory(DB_CONNECTION_STRING, MySqlDialect.Provider);
var db = dbFactory.Open();
Console.WriteLine(db.State.ToString());
db.Close();
db.Dispose();

Result

Open

However when I hit the SQL command

show full processlist;
Id          User    Host                  db       Command  Time    State   Info    Rows_sent   Rows_examined
81107052    user1   <111.21.96.32>:51120  my_db    Sleep    7       NULL    0   0
81107178    user1   localhost             my_db    Query    0       init    show full processlist   0   0
81107179    user1   localhost             my_db    Sleep    0       NULL    0   0

That process with id 81107052 is the process which started with code execution however, goes into sleep and does not terminate by db.Close(); This triggers <max_connections_reached> error with parallel application use.

So How do I close the connection process?


Solution

  • Adding Pooling=false is required in connection string