-
Notifications
You must be signed in to change notification settings - Fork 203
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
Upload: Keep the transaction around #1742
Conversation
With Mojo 7.88 Subprocesses are started not immediately anymore, but inside the IOLoop. To avoid transaction to vanish since it's weakened, explictly force it
Before: http://e122.suse.de/tests/22996 |
return Mojo::IOLoop->subprocess( | ||
sub { | ||
$tx; |
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.
This is just to make sure that $tx ends up in the coderef context right? , loooks like something is missing
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.
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.
Yea, the controller object (Mojolicious::Controller
) only keeps a weaked reference to the transaction ($c->tx
). So if you want to use code depending on the transaction (like $c->param(...)
) in async closures, you need to keep a strong reference to the transaction somewhere.
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.
From a framework design point of view this is a very tricky problem. If $c->tx
wasn't a weakened reference you wouldn't have this problem here, but pretty much every Mojolicious application using async features would be required to use Scalar::Util::weaken
all over the place or leak tons of memory with every request. So, i think this is actually the lesser evil. 😩
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.
@kraih Yeah, I guess so... having memory leaks all over the place sounds like a fun thing to debug :)
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.
Makes sense.
The failing fullstack test is unrelated (https://progress.opensuse.org/issues/39338).
Not so sure about the other failures but likely unrelated, too.
With Mojo 7.88 Subprocesses are started not immediately anymore, but
inside the IOLoop, a bit later. To avoid transaction to vanish since it's weakened,
explictly force it