SCM

[#1010415] Stream seek error on close

View Trackers | Bugs | Download .csv | Monitor

Date:
2008-06-19 23:00
Priority:
3
State:
Closed
Submitted by:
Patrick Earl (patearl)
Assigned to:
Nobody (None)
Npgsql Version:
None
Category:
Group:
Resolution:
Accepted
Summary:
Stream seek error on close

Detailed description
There is an error on close with 2.0beta4. I also saw the same error with 2.0beta2.

NHibernate.ADOException : Could not close Npgsql.NpgsqlConnection connection
System.NotSupportedException : This stream does not support seek operations.

at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
</message>
<message level="high">at System.IO.BufferedStream.FlushRead()</message>
<message level="high">at System.IO.BufferedStream.WriteByte(Byte value)</message>

at Npgsql.NpgsqlQuery.WriteToStream(Stream outputStream) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlQuery.cs:line 62

at Npgsql.NpgsqlReadyState.QueryEnum(NpgsqlConnector context, NpgsqlCommand command) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlReadyState.cs:line 64

at Npgsql.NpgsqlConnector.ReleasePlansPortals() in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnector.cs:line 373

at Npgsql.NpgsqlConnectorPool.UngetPooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnectorPool.cs:line 541

at Npgsql.NpgsqlConnectorPool.ReleasePooledConnector(NpgsqlConnection Connection, NpgsqlConnector Connector) in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnectorPool.cs:line 284

at Npgsql.NpgsqlConnection.Close() in C:\Npgsql\Npgsql2\src\Npgsql\NpgsqlConnection.cs:line 584

at NHibernate.Connection.ConnectionProvider.CloseConnection(IDbConnection conn) in C:\FormSoft Projects\dotNET\Lib\NHibernate-1.2.0.GA\src\NHibernate\Connection\ConnectionProvider.cs:line 31

Followup

Message
Date: 2008-10-24 07:11
Sender: Adrien Crivelli

Hi,

As stated previously I actually didn't use your patch... until yesterday when the exact same problem showed up again.

I still can't guess why it happens suddenly even though I saw some error during dropping schemas in my log.

Anyway I didn't look into it much further. Instead I used the patched DLL (the exact same one as last time) and the crash does not happen anymore.

So I confirm your patch fixed it. Thanks.
Date: 2008-08-29 19:27
Sender: Francisco Figueiredo jr.


Andrien, please check if you get this problem again with original dll. This occurs from time to time and not always. I hope this fix work always. So if you even get this problem again, try with this fixed version and test it for while and confirm if the problem goes away.

Thanks in advance.

I'm going to close this bug. If this problem persists, please, reopen the bug.
Date: 2008-08-29 19:25
Sender: Francisco Figueiredo jr.

Fix committed.
Date: 2008-08-29 08:54
Sender: Adrien Crivelli

Hi,

We tried your modification and it worked fine. However I tried one more time with the original DLL and it worked as well !

I can't really explain what happened but I thoroughly tested again both DLL on two computers. That time I deleted every single 'bin' and 'obj' folders to be totally sure to have a clean output for my project.

Somehow both DLL on both computers worked fine. I guess I messed up at some point in my previous tests. So we will stick to the original version.

Anyway thanks for your help.
Date: 2008-08-28 15:32
Sender: Francisco Figueiredo jr.


Hi all!

Can you try the following:

Add this line:

Connector.RequireReadyForQuery = true;

Just after the Connector.TestConnector() call in the NpgsqlConnectorPool.cs file

Recompile and give it a try.

I was playing with connection pool and noticed that sometimes the stream gets out of sync and Npgsql ends up letting some bytes in it. That's why you are getting this problem.

Thanks in advance.
Date: 2008-08-28 11:27
Sender: Adrien Crivelli

Hi,

I encountered the same error using ActiveRecord and NHibernate with Npgsql.

At the very beginning of my application ActiveRecord is supposed to drop database's schemas. But an ActiveRecordException is thrown (see dump below). The database is left untouched.

It used to work with Npgsql.dll 1.98.4.0 but it's broken with 1.99.1.0.

The problem is that I tried on three computers. It fails only on one of them and I can't seem to know what may be different.

All of them have Win XP, VS2008 SP1, .NET 3.5, and of course the exact same source code. They all run their own local postgres server. One working one has 8.2 installed whereas others have 8.3.



EXCEPTION DETAIL:

Castle.ActiveRecord.Framework.ActiveRecordException was unhandled
Message="Could not drop the schema"
Source="Castle.ActiveRecord"
StackTrace:
at Castle.ActiveRecord.ActiveRecordStarter.DropSchema()
at [...]

InnerException: NHibernate.ADOException
Message="Could not close Npgsql.NpgsqlConnection connection"
Source="NHibernate"
StackTrace:
at NHibernate.Connection.ConnectionProvider.CloseConnection(IDbConnection conn)
at NHibernate.Connection.DriverConnectionProvider.CloseConnection(IDbConnection conn)
at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script, Boolean export, Boolean justDrop, Boolean format)
at NHibernate.Tool.hbm2ddl.SchemaExport.Drop(Boolean script, Boolean export)
at Castle.ActiveRecord.ActiveRecordStarter.DropSchema()
InnerException: System.NotSupportedException
Message="This stream does not support seek operations."
Source="System"
StackTrace:
at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
at System.IO.BufferedStream.FlushRead()
at System.IO.BufferedStream.WriteByte(Byte value)
at Npgsql.NpgsqlQuery.WriteToStream(Stream outputStream)
at Npgsql.NpgsqlReadyState.QueryEnum(NpgsqlConnector context, NpgsqlCommand command)
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 NHibernate.Connection.ConnectionProvider.CloseConnection(IDbConnection conn)
InnerException:
Date: 2008-08-11 01:15
Sender: Francisco Figueiredo jr.


Hi, Patrick!

Do you have a simple test case or can you send us what are you using to get this error? This way we can add this test to our testsuite and work on it.

Thanks in advance.
Date: 2008-06-24 19:59
Sender: Patrick Earl

I got an error like: Unrecognized response type: q

Presumably the unrecognized response is breaking the stream.
Date: 2008-06-24 19:40
Sender: Patrick Earl

After further investigation, it looks like the connection is
not recovering after an error. Executing a command after
the connection had an error causes problems.
Date: 2008-06-24 19:33
Sender: Patrick Earl

This issue is potentially being caused by a previous error
on the connection. Is there any way to get close to ignore
previous errors on the connection and succeed silently?

Attached Files:

Attachments:
ResponseTypeQ.jpg

Changes:

Field Old Value Date By
status_idOpen2008-08-29 19:27fxjr
ResolutionNone2008-08-29 19:27fxjr
close_date2008-08-29 19:272008-08-29 19:27fxjr
File Added339: ResponseTypeQ.jpg2008-06-24 20:18patearl
Powered By FusionForge