[fix][broker] PIP-468: don't let namespace consumers auto-recreate deleted scalable topics#26066
Open
merlimat wants to merge 1 commit into
Open
[fix][broker] PIP-468: don't let namespace consumers auto-recreate deleted scalable topics#26066merlimat wants to merge 1 commit into
merlimat wants to merge 1 commit into
Conversation
…leted scalable topics PIP-468 scalable topics auto-create on lookup when broker/namespace policy allows. A V5 namespace (multi-topic) consumer opens a per-topic DAG-watch for each matching topic; when a topic is deleted the namespace watcher tells the consumer to drop it, but a per-topic watch that reconnects during the teardown window would re-run the lookup and, with auto-creation enabled, resurrect the just-deleted topic. Relying on the close-vs-reconnect race is not a guarantee. Make it deterministic with a create-if-missing flag on the per-topic connect: - Add optional 'create_if_missing' (default true) to CommandScalableTopicLookup. The default preserves auto-create-on-lookup for explicit single-topic producers/consumers and for older clients that don't set it. - DagWatchClient carries the flag; the namespace consumer (MultiTopicQueueConsumer) opens its per-topic watches with create_if_missing=false. - DagWatchSession honors it: a topic:// lookup of a missing topic with create_if_missing=false fails not-found before consulting policy or creating, so a deleted topic is never resurrected by a reconnecting namespace-consumer watch. Scope: gates the lookup path used by the queue namespace consumer. The stream namespace consumer uses a different subscribe path that does not go through auto-create-on-lookup.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
PIP-468 scalable topics auto-create on lookup when broker/namespace policy allows. A V5 namespace
(multi-topic) consumer opens a per-topic DAG-watch for each scalable topic matching its property
filters. When a topic is deleted, the namespace watcher notifies the consumer, which stops the
per-topic consumer for it — but a per-topic watch that reconnects during the deletion teardown
window would re-run the lookup and, with auto-creation enabled, resurrect the just-deleted
topic. Relying on the close-vs-reconnect race to avoid this is not a guarantee.
A namespace consumer should only ever attach to topics that already exist (the watcher tells it
which); it must never create one.
Modifications
create_if_missingfield (defaulttrue) toCommandScalableTopicLookup. Thedefault preserves the auto-create-on-lookup behavior for explicit single-topic producers/consumers
and for older clients that don't set the field.
DagWatchClientcarries the flag; the V5 namespace consumer (MultiTopicQueueConsumer) opens itsper-topic watches with
create_if_missing=false.DagWatchSessionhonors it: atopic://lookup of a missing topic withcreate_if_missing=falsefails not-found before consulting policy or creating anything — so adeleted topic can never be resurrected by a reconnecting namespace-consumer watch, deterministically
rather than by winning a race.
Scope: this gates the lookup path used by the queue namespace consumer. The stream namespace
consumer uses a different subscribe path (
ScalableTopicSubscribe→ controller) that does not gothrough auto-create-on-lookup.
Verifying this change
DagWatchSessionTest.testStartDoesNotAutoCreateWhenCallerOptsOut— broker-side gating: withcreate_if_missing=false, a missingtopic://lookup fails not-found and never consults policy orcreates the topic.
V5NamespaceConsumerTopicDeletionTest(new) — namespace consumer with property filters: onlymatching topics attach; deleting a matched topic stops its per-topic consumer; the deleted topic
stays gone across auto-discovery cycles (broker auto-creation enabled, so this would fail if the
consumer resurrected it).
V5ScalableTopicAutoCreateTest) and the multi-topicconsumers (
V5MultiTopicQueueConsumerTest,V5MultiTopicStreamConsumerTest,V5ScalableTopicsWatcherTest) are unaffected.