SCM

[#1011141] Exception when used in multi-threaded server and the database engine getting disconnected midway !

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-12-27 01:33
Priority:
3
State:
Open
Submitted by:
rajasekaran subramanian (rajasekaran2003)
Assigned to:
Nobody (None)
Npgsql Version:
None
Category:
Group:
Resolution:
None
Summary:
Exception when used in multi-threaded server and the database engine getting disconnected midway !

Detailed description
This is an example given in the manual. When I try the same in multi-threaded fashion, I get exceptions.
using(NpgsqlConnection conn = new NpgsqlConnection("connstring"))
{
conn.Open();
using(NpgsqlCommand command = new NpgsqlCommand("select command", conn))
{
command.Parameters.Add(new NpgsqlParameter("column1", NpgsqlDbType.Integer);
command.Parameters[0].Value = 4;
using(NpgsqlDataReader dr = command.ExecuteReader())
{
dr.Read();
Console.Write("{0} \t", dr[0]);
}
}
}
Exception :

System exception System.IO.IOException: I/O error occurred.
at Npgsql.NpgsqlState.<ProcessBackendResponses_Ver_3>d__a.MoveNext()
at Npgsql.NpgsqlState.IterateThroughAllResponses(IEnumerable`1 ienum)
at Npgsql.NpgsqlState.Query(NpgsqlConnector context, NpgsqlCommand command)
at Npgsql.NpgsqlConnector.Query(NpgsqlCommand queryCommand)
at Npgsql.NpgsqlConnector.ReleaseRegisteredListen()
at Npgsql.NpgsqlConnector.ReleaseResources()
at Npgsql.NpgsqlConnectorPool.UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleasePooledConnectorInternal(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleasePooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnectorPool.ReleaseConnector(NpgsqlConnection Connection, NpgsqlConnector Connector)
at Npgsql.NpgsqlConnection.Close()
at Npgsql.NpgsqlConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()


Now this works correctly when the datareader is not used with Idisposable.

using(NpgsqlConnection conn = new NpgsqlConnection("connstring"))
{
conn.Open();
using(NpgsqlCommand command = new NpgsqlCommand("select command", conn))
{
command.Parameters.Add(new NpgsqlParameter("column1", NpgsqlDbType.Integer);
command.Parameters[0].Value = 4;
NpgsqlDataReader dr = command.ExecuteReader();
dr.Read();
Console.Write("{0} \t", dr[0]);
}
}

To reproduce : I would suggest you load test it with parallel running threads and a few more sequential(heavy load) and disconnecting on the server side. You will be able to reproduce this. In my case, it is the case disconnecting after sending the result.Server disconnects itself after sending the result for the query and on disconnecting, there are some threads in processing, that's when the exception occurs.




The entire discussion on this with Francisco - http://stackoverflow.com/questions/8584055/npgsql-strange-exception

Followup

No Followups Have Been Posted

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge