Skip to content

NH-4013 - SQL-Server batcher failure after CloseCommands. #628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 8, 2017

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented May 20, 2017

NH-4013 - SqlClientBatchingBatcher CloseCommands contract violated

CloseCommands causes SqlClientBatchingBatcher and MySqlClientBatchingBatcher to be unusable although its xml comment states:

/// Use this method instead of <c>Dispose</c> if the <see cref="IBatcher"/>
/// can be used again.

Test case and fix.

Copy link
Member Author

@fredericDelaporte fredericDelaporte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQL-Server batcher and MySql batcher have much in common, but this is not the case of Oracle batcher. So we may refactor this with an additional abstract class, but I am not much inspired by the idea of introducing this for some cases and not for others. (And how to name that? MySqlServerBatcherBase?)

@@ -74,7 +74,6 @@ protected override void DoExecuteBatch(DbCommand ps)
if (Factory.Settings.SqlStatementLogger.IsDebugEnabled)
{
Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString());
currentBatchCommandsLog = new StringBuilder().AppendLine("Batch commands:");
Copy link
Member Author

@fredericDelaporte fredericDelaporte May 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to ClearCurrentBatch.

@hazzik
Copy link
Member

hazzik commented May 30, 2017

You still have the same issue as #513

@fredericDelaporte
Copy link
Member Author

#513 looks invalid as an issue to me, since we are not supposed to reuse the session (and hence its batcher) after a failure. So for me there is no point trying to fix such case. Unless we intend someday to enable session recovering from failures.

Here I fix a "no exception" case, where calling CloseCommands causes the batcher to be no more usable while it should still be. This case may happen in almost "normal use" cases, when an user open a reader then commit a transaction without having closed the reader, while not using OnClose connection release mode.

@fredericDelaporte
Copy link
Member Author

And now that is #513 which is "behind", since it will still leave the batcher unusable in case of preparation failure (network error or whatever). I think that is a bit non-sens to change code for an explicitly unsupported use case like re-using the session after an exception. The batcher will still be unusable if the failure occurs outside of DoExecuteBatch by example.

@fredericDelaporte
Copy link
Member Author

Rebased for forcing rebuild, failure on teamcity side (xml report truncated).

Copy link
Member

@hazzik hazzik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@fredericDelaporte fredericDelaporte merged commit 71d5e2e into nhibernate:master Jun 8, 2017
@fredericDelaporte fredericDelaporte added this to the 5.0.0 milestone Jun 8, 2017
@fredericDelaporte fredericDelaporte deleted the NH-4013 branch June 8, 2017 15:42
@hazzik hazzik added the r: Fixed label Aug 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants