{"record":{"id":"bf05d8dec75b2faa","repo":"crowdsecurity/crowdsec","slug":"consumer-s-is-not-deregistered-after-d-tries","errorCode":null,"errorMessage":"consumer %s is not deregistered after %d tries","messagePattern":"consumer (.+?) is not deregistered after (.+?) tries","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kinesis/run.go","lineNumber":90,"sourceCode":"\t\t_, err := s.kClient.DescribeStreamConsumer(ctx, &kinesis.DescribeStreamConsumerInput{\n\t\t\t\tConsumerName: aws.String(consumerName),\n\t\t\t\tStreamARN:    aws.String(streamARN),\n\t\t\t})\n\n\t\tvar resourceNotFoundErr *kinTypes.ResourceNotFoundException\n\t\tif errors.As(err, &resourceNotFoundErr) {\n\t\t\treturn nil\n\t\t}\n\n\t\tif err != nil {\n\t\t\ts.logger.Errorf(\"Error while waiting for consumer deregistration: %s\", err)\n\t\t\treturn fmt.Errorf(\"cannot describe stream consumer: %w\", err)\n\t\t}\n\n\t\ttime.Sleep(time.Millisecond * 200 * time.Duration(i+1))\n\t}\n\n\treturn fmt.Errorf(\"consumer %s is not deregistered after %d tries\", consumerName, maxTries)\n}\n\nfunc (s *Source) DeregisterConsumer(ctx context.Context) error {\n\ts.logger.Debugf(\"Deregistering consumer %s if it exists\", s.Config.ConsumerName)\n\t_, err := s.kClient.DeregisterStreamConsumer(ctx, &kinesis.DeregisterStreamConsumerInput{\n\t\t\tConsumerName: aws.String(s.Config.ConsumerName),\n\t\t\tStreamARN:    aws.String(s.Config.StreamARN),\n\t\t})\n\n\tvar resourceNotFoundErr *kinTypes.ResourceNotFoundException\n\tif errors.As(err, &resourceNotFoundErr) {\n\t\treturn nil\n\t}\n\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot deregister stream consumer: %w\", err)\n\t}\n","sourceCodeStart":72,"sourceCodeEnd":108,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kinesis/run.go#L72-L108","documentation":"Returned by WaitForConsumerDeregistration when the consumer never disappears (or never errors) after `MaxRetries` DescribeStreamConsumer polls with increasing 200ms*i backoff. AWS guarantees deletion is quick but asynchronous; this means it stayed visible past the polling budget.","triggerScenarios":"DeregisterConsumer succeeded but repeated DescribeStreamConsumer calls keep returning the consumer with status DELETING for maxTries iterations (default MaxRetries from config).","commonSituations":"Heavily loaded streams where deletion is slow; very low `max_retries` in config; region mismatch causing polls against a copy where the consumer still exists (unlikely but possible with misconfigured endpoints).","solutions":["Increase `max_retries` in the kinesis acquisition config to extend the polling window.","Wait a few seconds and re-run; consumer deletion is asynchronous and usually completes shortly after.","Verify with `aws kinesis describe-stream-consumer --consumer-name <name> --stream-arn <arn>` whether the consumer is genuinely stuck, and contact AWS support if DELETING persists for minutes.","Check the region configured matches the stream's region so polling hits the right endpoint."],"exampleFix":"// before\nmax_retries: 3\n// after\nmax_retries: 10","handlingStrategy":"retry","validationCode":"// Before deregistering, confirm consumer state\nout, err := client.DescribeStreamConsumer(ctx, &kinesis.DescribeStreamConsumerInput{ConsumerARN: aws.String(arn)})\nif err == nil && out.ConsumerDescription.ConsumerStatus != nil && *out.ConsumerDescription.ConsumerStatus == \"DELETING\" {\n    // deletion already in flight; allow extra polling budget\n}","typeGuard":null,"tryCatchPattern":"err := waitForDeregistration(ctx, name, arn)\nif err != nil {\n    var to *TimeoutError\n    if errors.As(err, &to) { logger.Warn(\"consumer deletion still in flight; proceeding idempotently\") }\n}","preventionTips":["Set max_retries high enough (>=10) to cover multi-second AWS deletion latency.","Don't recreate a consumer with the same name until the old one is gone (name is unique per stream while deleting).","Avoid deregister/register churn in hot reload loops."],"tags":["aws","kinesis","timeout"],"backgroundTag":"request-timeout","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}