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

Log messages are also rolled back with job transactions! #22

Closed
hidegh opened this issue Sep 17, 2024 · 2 comments
Closed

Log messages are also rolled back with job transactions! #22

hidegh opened this issue Sep 17, 2024 · 2 comments

Comments

@hidegh
Copy link

hidegh commented Sep 17, 2024

Never noticed before, but testing is simple.
We just need a job, 1 transaction scope that commits, and 1 that rolls back.

Issues:

  • Logged message to the console disappears (also rolls back) in case of the 2nd transaction.
  • Also until TX is committed, no logs are showing!

Expected behavior:

  • Logging should be independent (separate transaction or outside transactions).
  • Log messages shows up immediately (not just when TX commits)

image

        jobProgress.WriteProgressLine(LogLevel.Information, "Before tran #1");
        using (var ts = TransactionScopeBuilder.New())
        {
            jobProgress.WriteProgressLine(LogLevel.Information, "Inside tran with commit");
            ts.Complete();
        }
        jobProgress.WriteProgressLine(LogLevel.Information, "After tran #1");

        jobProgress.WriteProgressLine(LogLevel.Information, "Before tran #2");
        using (var ts = TransactionScopeBuilder.New())
        {
            jobProgress.WriteProgressLine(LogLevel.Information, "Inside tran without commit");
            // rollback: ts.Complete();
        }
        jobProgress.WriteProgressLine(LogLevel.Information, "After tran #2");
@AnderssonPeter
Copy link
Owner

Are you sure this is an issue with this nuget and not the underlying console nuget? From what I remember there is no transaction logic in the code of this nuget.

@hidegh
Copy link
Author

hidegh commented Sep 17, 2024

Thanx, you're probably right...for those with same issue, just add reactions here: pieceofsummer/Hangfire.Console#134

Solution (patch) available there...

Also on the same spot (URL), (based on your implementations) there's a custom IProgress and IProgressBar implementation, which made it super easy to patch this odd behavior until (if) a fix is released.

@hidegh hidegh closed this as completed Sep 17, 2024
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

No branches or pull requests

2 participants