Skip to content

Connection pooling interfering with PubSub #194

@wilg

Description

@wilg

I'm trying to debug an issue with my Redis PubSub where it's throwing a warning about "(RediStack) connection attempted to create a PubSub subscription".

I think what may be happening is that the PubSub code below pulls a connection out of the connection pool, but does not remove it from the pool. Meaning eventually that connection that is performing PubSub will get vended back out to some consumer, and because it has been placed in PubSub mode, will no longer be able to send.

var pubsubClient: RedisClient {
if let existing = self.application.storage[PubSubKey.self]?[self.id] {
return existing
} else {
let lock = self.application.locks.lock(for: PubSubKey.self)
lock.lock()
defer { lock.unlock() }
let pool = self.pool(for: self.eventLoop.next())
if let existingStorage = self.application.storage[PubSubKey.self] {
var copy = existingStorage
copy[self.id] = pool
self.application.storage.set(PubSubKey.self, to: copy)
} else {
self.application.storage.set(PubSubKey.self, to: [self.id: pool])
}
return pool
}
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions