E524 [Messenger] Only send `UNLISTEN` query if we are actively listening by jwage · Pull Request #63202 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@jwage
Copy link
Contributor
@jwage jwage commented Jan 26, 2026
Q A
Branch? 6.4
Bug fix? yes (maybe?)
New feature? no
Deprecations? no
License MIT

I was looking at some slow traces and noticed PostgreSqlConnection::unlisten() being called in the __destruct even when we are using the connection to publish only and we're not consuming, yet on the __destruct() it still send a transaction to pgsql to UNLISTEN when we're not listening.

Screenshot 2026-01-26 at 3 38 03 PM

@carsonbot carsonbot added this to the 6.4 milestone Jan 26, 2026
@jwage jwage force-pushed the optimize-listen-notify branch 3 times, most recently from bf7f7ae to 0d51464 Compare January 26, 2026 20:57
@OskarStark OskarStark changed the title [Messenger] Only send UNLISTEN query if we are actively listening. [Messenger] Only send UNLISTEN query if we are actively listening Jan 27, 2026
@OskarStark OskarStark changed the title [Messenger] Only send UNLISTEN query if we are actively listening [Messenger] Only send UNLISTEN query if we are actively listening Jan 27, 2026

private function unlisten(): void
{
if (false === $this->listening) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
if (false === $this->listening) {
if (true === (false === $this->listening)) {

or maybe just this?

Suggested change
if (false === $this->listening) {
if (!$this->listening) {

(kidding 😜 )

@nicolas-grekas
Copy link
Member

Thank you @jwage.

@nicolas-grekas nicolas-grekas merged commit a2dfc9e into symfony:6.4 Jan 27, 2026
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.

4 participants

0