nats-io / nats-server

High-Performance server for NATS.io, the cloud and edge native messaging system.
https://nats.io
Apache License 2.0
16k stars 1.41k forks source link

[FIXED] Ghost consumers during meta recovery #6092

Closed MauriceVanVeen closed 1 week ago

MauriceVanVeen commented 1 week ago

During meta recovery ru.updateConsumers and ru.removeConsumers would not be properly cleared since the move from map[string]*consumerAssignment to map[string]map[string]*consumerAssignment. Which meant that consumers that needed to be removed were both in ru.removeConsumers and left in ru.updateConsumers. Resulting in a ghost consumer.

Also don't clear recovering state while we still have items to process as part of recovery.

De-flakes TestJetStreamClusterLostConsumers, and makes TestJetStreamClusterConsumerLeak more reliable by re-introducing the ca.pending flag. Since the consumer leader responds for consumer creation, but meta leader responds for consumer deletion, so need to have the consumer assignment available so meta leader can respond successfully.

Signed-off-by: Maurice van Veen github@mauricevanveen.com