-
Notifications
You must be signed in to change notification settings - Fork 32
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
Outbox improvements #439
Outbox improvements #439
Conversation
f8027ca
to
b799379
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pessimistic outbox would not work with snapshot isolation level. Maybe add a check to ensure the customer isn't doing this?
|
||
public override Task Complete(string endpointQualifiedMessageId, ISession session, OutboxMessage outboxMessage, ContextBag context) | ||
{ | ||
var queryString = $"update {typeof(TEntity).Name} set TransportOperations = :ops where MessageId = :messageid"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SzymonPobiega The entity was already saved and from that moment on I think it is tracked so why not do ISession.Flush
here? Probably Flush is already called somewhere else so this seems unneeded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, it does not work. This is the only way I was able to force NH to actually hit the database here. Neither Flush nor explicitly calling Lock
helped.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SzymonPobiega That is strange, it is the same nhibernate session right? I just checked, the entity is tracked once Save has been called and any changes on it will result in an UPDATE after any Flush or Commit. Don't get fooled by show_sql
, as the UPDATE does happen, it just isn't logged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm. Ok. I'll try to go through it with a profiler tomorrow. Why would show_sql
not show the updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SzymonPobiega show_sql
only works reliably if you disable batching adonet.batch_size=0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ramonsmits I replaced this code with
record.TransportOperations = ConvertOperations(outboxMessage);
return session.FlushAsync();
and checked in the profiler and it does not issue an update
so leaving the HQL. One we release this, feel free to created a PR to fix it if you find a way to force NH to flush the changes.
That would be a good idea but I think this is too complex to get right. I think it will be enough to mention in the doco. Users need to enable pessimistic mode anyway... |
@tmasternak @dvdstelt can you review this one? |
bcbb003
to
bc364a1
Compare
TransactionScope outbox Graceful outbox cleaner shutdown
bc364a1
to
4370155
Compare
Replaces #438 (includes that one and also transaction scope support)