Repository navigation
Fixed reading by reader previous query messages - #3126
Conversation
ae45f2b to
9de9876
Compare
9de9876 to
2b42406
Compare
roji
left a comment
There was a problem hiding this comment.
Sorry for taking so long to review this - the approach looks great, see the comment on the Cleanup placement inside Read.
There's also the question of exceptions happening during sequential column reads - this wasn't handled before either, but we could handle it by cleaning up in GetFieldValueSequential as well.
roji
left a comment
There was a problem hiding this comment.
Looks good, but just want to make sure we still close the connection with CommandBehavior.CloseConnection when an error occurs.
@roji not really - if there was an exception while reading sequentially, it will break the connection (which also closes the reader). |
|
(we could even a test that confirms the close-on-error behavior, using mocking) |
|
As discussed offline, the current idea is to do the same, as we've done for the transactions. That is, if the reader is closed outside of dispose, we unbind it from the connector. |
roji
left a comment
There was a problem hiding this comment.
As discussed offline, the current idea is to do the same, as we've done for the transactions. That is, if the reader is closed outside of dispose, we unbind it from the connector.
@vonzshik, shouldn't we unbind the reader only if the connection is closed with an undisposed reader, like we do with transactions? The way the code currently is, if a user just calls Close on a reader, we immediately unbind even if they do Dispose right afterwards (before closing the connection).
I'd expect BindIfNecessary to only get called from EndBindingScope and Reset, just like with transactions, no?
|
@roji changed a little, now it should be a little bit more sane |
roji
left a comment
There was a problem hiding this comment.
Thanks @vonzshik, the recycling looks much better now.
I thought about this thoroughly again, and noticed that we now call Cleanup on any error in Read/NextResult, whereas before we used to call it only on PostgresException (note also that we don't call Cleanup if an exception occurs in other reader methods, e.g. GetFieldValue (sequential), ColumnStream).
I thought about this some more, and I'm no longer sure why things are this way - rather than call Cleanup immediately when an exception occurs, why not defer and do it as usual only when the user closes/disposes the reader? This would make the flow simpler and wouldn't create an inconsistency between Read/NextResult and GetFieldValue/ColumnStream, etc.
If this works and I'm not missing anything, we'd also need to call Cleanup in NpgsqlCommand.ExecuteReader when an exception occurs (where we now call only EndUserAction).
What do you think?
603150d to
d078adb
Compare
roji
left a comment
There was a problem hiding this comment.
LGTM - though see the last outstanding comment about refactoring cleanup flow in NpgsqlCommand.
c43e316 to
7cc58d6
Compare
Fixed compilation
This reverts commit c46d283.
7cc58d6 to
34f4774
Compare
|
@roji seems to be stable now, just one final check |
Closes #2913
Closes #3289
Closes #2964
The idea is to move reader cleanup from a connector to the reader.