diff --git a/src/rdkafka_cgrp.c b/src/rdkafka_cgrp.c index 2e66debe93..ea2f50164e 100644 --- a/src/rdkafka_cgrp.c +++ b/src/rdkafka_cgrp.c @@ -2333,6 +2333,10 @@ static int rd_kafka_cgrp_metadata_refresh(rd_kafka_cgrp_t *rkcg, rd_list_init(&topics, 8, rd_free); + /* Insert all non-wildcard topics in cache. */ + rd_kafka_metadata_cache_hint_rktparlist( + rkcg->rkcg_rk, rkcg->rkcg_subscription, NULL, 0 /*dont replace*/); + if (rkcg->rkcg_flags & RD_KAFKA_CGRP_F_WILDCARD_SUBSCRIPTION) { /* For wildcard subscriptions make sure the * cached full metadata isn't too old. */ @@ -5007,8 +5011,9 @@ rd_kafka_cgrp_subscription_set(rd_kafka_cgrp_t *rkcg, rkcg->rkcg_subscription = rktparlist; if (rkcg->rkcg_subscription) { /* Insert all non-wildcard topics in cache immediately. - * to avoid problems with subsequent metadata - * requests. */ + * Otherwise a manual full metadata request could + * not cache the hinted topic and return an + * UNKNOWN_TOPIC_OR_PART error to the user. See #4589. */ rd_kafka_metadata_cache_hint_rktparlist( rkcg->rkcg_rk, rkcg->rkcg_subscription, NULL, 0 /*dont replace*/);