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

Outbox improvements #439

Merged
merged 2 commits into from
Jun 22, 2020
Merged

Outbox improvements #439

merged 2 commits into from
Jun 22, 2020

Conversation

SzymonPobiega
Copy link
Member

Replaces #438 (includes that one and also transaction scope support)

  • Introduce pessimistic mode
  • Introduce transaction scope support

Copy link
Member

@ramonsmits ramonsmits left a 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";
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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.

@SzymonPobiega
Copy link
Member Author

Pessimistic outbox would not work with snapshot isolation level. Maybe add a check to ensure the customer isn't doing this?

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
tmasternak previously approved these changes Jun 22, 2020
@SzymonPobiega
Copy link
Member Author

@tmasternak @dvdstelt can you review this one?

@SzymonPobiega SzymonPobiega force-pushed the transaction-scope-outbox branch from bcbb003 to bc364a1 Compare June 22, 2020 12:03
TransactionScope outbox

Graceful outbox cleaner shutdown
@SzymonPobiega SzymonPobiega force-pushed the transaction-scope-outbox branch from bc364a1 to 4370155 Compare June 22, 2020 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants