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

Upload: Keep the transaction around #1742

Merged
merged 1 commit into from
Aug 8, 2018

Conversation

mudler
Copy link
Member

@mudler mudler commented Aug 8, 2018

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

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
@mudler
Copy link
Member Author

mudler commented Aug 8, 2018

Before: http://e122.suse.de/tests/22996
After: http://e122.suse.de/tests/23066#downloads
Thanks @kraih for the pointers

return Mojo::IOLoop->subprocess(
sub {
$tx;
Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Member

@kraih kraih Aug 8, 2018

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. 😩

Copy link
Member

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 :)

Copy link
Contributor

@Martchus Martchus left a 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.

@foursixnine foursixnine merged commit 5185383 into os-autoinst:master Aug 8, 2018
@mudler mudler deleted the keep_tx_ref branch August 8, 2018 14:36
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.

None yet

4 participants