{"record":{"id":"e76ca55415e526ad","repo":"crowdsecurity/crowdsec","slug":"consumer-s-is-not-active-after-d-tries","errorCode":null,"errorMessage":"consumer %s is not active after %d tries","messagePattern":"consumer (.+?) is not active after (.+?) tries","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kinesis/run.go","lineNumber":136,"sourceCode":"\tmaxTries := s.Config.MaxRetries\n\tfor i := range maxTries {\n\t\tdescribeOutput, err := s.kClient.DescribeStreamConsumer(ctx, &kinesis.DescribeStreamConsumerInput{\n\t\t\t\tConsumerARN: aws.String(consumerARN),\n\t\t\t})\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cannot describe stream consumer: %w\", err)\n\t\t}\n\n\t\tif describeOutput.ConsumerDescription.ConsumerStatus == \"ACTIVE\" {\n\t\t\ts.logger.Debugf(\"Consumer %s is active\", consumerARN)\n\t\t\treturn nil\n\t\t}\n\n\t\ttime.Sleep(time.Millisecond * 200 * time.Duration(i+1))\n\t\ts.logger.Debugf(\"Waiting for consumer registration %d\", i)\n\t}\n\n\treturn fmt.Errorf(\"consumer %s is not active after %d tries\", consumerARN, maxTries)\n}\n\nfunc (s *Source) RegisterConsumer(ctx context.Context) (*kinesis.RegisterStreamConsumerOutput, error) {\n\ts.logger.Debugf(\"Registering consumer %s\", s.Config.ConsumerName)\n\n\tstreamConsumer, err := s.kClient.RegisterStreamConsumer(ctx, &kinesis.RegisterStreamConsumerInput{\n\t\t\tConsumerName: aws.String(s.Config.ConsumerName),\n\t\t\tStreamARN:    aws.String(s.Config.StreamARN),\n\t\t})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"cannot register stream consumer: %w\", err)\n\t}\n\n\terr = s.WaitForConsumerRegistration(ctx, *streamConsumer.Consumer.ConsumerARN)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"timeout while waiting for consumer to be active: %w\", err)\n\t}\n","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kinesis/run.go#L118-L154","documentation":"Returned by WaitForConsumerRegistration when the consumer never reaches ACTIVE status within `MaxRetries` polls (each 200ms*(i+1) apart). Kinesis EFO consumers typically take seconds to activate; this error means the polling budget was exhausted.","triggerScenarios":"RegisterConsumer succeeded, but repeated DescribeStreamConsumer calls keep returning CREATING until maxTries is hit; RegisterConsumer then wraps it as \"timeout while waiting for consumer to be active\".","commonSituations":"Consumer activation under heavy stream load taking longer than the default budget; very small `max_retries` in config; localstack/test environments where activation is slower or mocked inconsistently.","solutions":["Increase `max_retries` in the kinesis acquisition config (e.g. from a few to 15-30) to extend the ~200ms-growing backoff window.","Just restart the acquisition — the consumer persists and may already be ACTIVE; DescribeStreamConsumer on an existing consumer name returns its state.","Check for account-level consumer limits (up to 20 per stream) — if exhausted, deregister stale consumers.","For localstack dev environments, verify the version supports EFO consumer APIs properly."],"exampleFix":"// before\nmax_retries: 3\n// after\nmax_retries: 20","handlingStrategy":"retry","validationCode":"// Check current consumer state and count before starting EFO\nconsumers, err := client.ListStreamConsumers(ctx, &kinesis.ListStreamConsumersInput{StreamARN: aws.String(arn)})\nif err != nil { return err }\nif len(consumers.Consumers) >= 20 { return errors.New(\"stream at EFO consumer limit\") }","typeGuard":null,"tryCatchPattern":"if err := waitForActive(ctx, arn); err != nil {\n    select {\n    case <-ctx.Done():\n        return ctx.Err()\n    case <-time.After(2 * time.Second):\n        return waitForActive(ctx, arn) // one extra round before giving up\n    }\n}","preventionTips":["Set max_retries to cover ~10+ seconds of activation time (polls grow by 200ms each).","Reuse an existing ACTIVE consumer instead of registering a new one each restart.","Monitor activation latency in CloudWatch when running many consumers per stream."],"tags":["aws","kinesis","timeout","efo"],"backgroundTag":"request-timeout","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}