Skip to content

Always attempt to listen for notifications #47209

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

Merged
merged 1 commit into from
Aug 9, 2022

Conversation

goetas
Copy link
Contributor

@goetas goetas commented Aug 6, 2022

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets #45056
License MIT

as discussed in #45056 (comment), when a middleware closes the connection, the messenger consumer will not receive notifications when a new record is inserted.

Since is safe to call LISTEN multiple times, we can avoid having to keep tack if we did call or not the listen command, we call it always so we are always sure to get notifications with new messages are added.

@goetas
Copy link
Contributor Author

goetas commented Aug 6, 2022

I've also added a test but i'm not sure it is worth the effort

@goetas goetas force-pushed the pg-listen-close-connect branch from d2dd112 to 5700919 Compare August 6, 2022 06:47
@fabpot fabpot requested a review from dunglas August 6, 2022 08:19
@dunglas
Copy link
Member

dunglas commented Aug 7, 2022

If we're sure that it's safe to call LISTEN multiple times (I didn't find any information about that in the manual), then +1 on my side!

Copy link
Member

@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

It is mentioned in the LISTEN docs that calling it when psql is already listening, does nothing. So, it looks like it "safe".

@fabpot
Copy link
Member

fabpot commented Aug 7, 2022

@goetas Can you have a look at the tests, https://github.com/symfony/symfony/runs/7711529784?check_suite_focus=true might be related to this change.

Comment on lines 53 to 57
public function reset()
{
parent::reset();
$this->unlisten();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we want to keep this? we still want to unlisten on reset, don't we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i have reverted a portion of this. I have also verified that calling UNLISTEN multiple times makes no harm

Copy link
Contributor

@bendavies bendavies left a comment

Choose a reason for hiding this comment

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

thanks for taking this on !

@goetas goetas force-pushed the pg-listen-close-connect branch 2 times, most recently from eaa0b31 to b462665 Compare August 7, 2022 19:42
};

// dbal 2.x
if (interface_exists(Result::class)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to do this weird thing to test against dbal 2.x and dbal 3.x. I'm not proud of it but i do not have a better idea

Copy link
Member

Choose a reason for hiding this comment

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

You could maybe duplicate the test to remove the if (and skip if not using the good version). But IMHO that's good enough as-is.

@goetas
Copy link
Contributor Author

goetas commented Aug 7, 2022

Can you have a look at the tests, https://github.com/symfony/symfony/runs/7711529784?check_suite_focus=true might be related to this change.

I have fixed the test, it was because i had locally dbal 3.x instlled while on CI 2.x is runing. https://github.com/symfony/symfony/pull/47209/files#r939714144 does a different mocking by trying to detect which dbal is running

@fabpot fabpot force-pushed the pg-listen-close-connect branch from b462665 to 72ac5bf Compare August 9, 2022 12:54
@fabpot
Copy link
Member

fabpot commented Aug 9, 2022

Thank you @goetas.

@fabpot fabpot merged commit d0199b4 into symfony:5.4 Aug 9, 2022
This was referenced Aug 26, 2022
@fabpot fabpot mentioned this pull request Sep 30, 2022
d-ph pushed a commit to d-ph/symfony that referenced this pull request Dec 9, 2022
…es with custom consumption priorities. Replay symfony#47209 on top of this code change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants