Skip to content
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

Fix stateless batcher #2755

Merged

Conversation

fredericDelaporte
Copy link
Member

Fix #2750.

@@ -351,7 +363,7 @@ public override bool IsOpen

public override FlushMode FlushMode
{
get { return FlushMode.Commit; }
get { return FlushMode.Always; }
Copy link
Member Author

Choose a reason for hiding this comment

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

This is more consistent with the stateless semantic of a stateless session, and also with:

public FlushMode InitialSessionFlushMode => FlushMode.Always;

(That is in the stateless session builder.)

@hazzik
Copy link
Member

hazzik commented May 15, 2021

Need to restrict tests to the providers that support distributed transactions.

@fredericDelaporte
Copy link
Member Author

I have amended the "more test" commit and rebased.

{
session.Insert(entity);
}
session.FlushBatcher();
Copy link
Member

Choose a reason for hiding this comment

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

StatelessSession has ManagedFlush method which is not exposed through interface. Maybe we should expose it instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

I choosed FlushBatcher rather than just Flush because in principle the stateless session should never need a Flush, since it is stateless. So I want to stress what this flush is for: flushing the batcher that can be enabled with the stateless session, and which may retain some operations not yet sent to the database.

Copy link
Member

Choose a reason for hiding this comment

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

Just wanted to clarify that I'm not talking about the general Flush method, but about ManagedFlush.

Copy link
Member Author

Choose a reason for hiding this comment

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

In the case of the stateless session, that is the same.

But anyway, what does it mean, ManagedFlush? I do not make any sense of it. FlushBatcher is explicit about its purpose, while that is not the case of ManagedFlush in my opinion.

public override void Flush()
{
ManagedFlush(); // NH Different behavior since ADOContext.Context is not implemented
}
public void ManagedFlush()
{
using (BeginProcess())
{
Batcher.ExecuteBatch();
}
}

@fredericDelaporte fredericDelaporte merged commit 3d3ed91 into nhibernate:master May 29, 2021
@fredericDelaporte fredericDelaporte deleted the statelessBatcher branch May 29, 2021 18:11
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.

Using System.Transaction with IStatelessSession doesn't always flush batches to database
2 participants