shashank created CAMEL-27458:
--------------------------------

             Summary: camel-aws2-kinesis - the consumer is reported ready and 
healthy while ListShards fails, and reads nothing
                 Key: CAMEL-27458
                 URL: https://issues.apache.org/jira/browse/CAMEL-27458
             Project: Camel
          Issue Type: Bug
          Components: camel-aws2-kinesis
            Reporter: shashank
            Assignee: shashank


h3. What happens

The polling consumer (without {{useKclConsumers}}) reads the shards of the list 
that its shard monitor gets with {{ListShards}} every {{shardMonitorInterval}}; 
since CAMEL-24197 this is also the case with a configured {{shardId}}, which 
called {{DescribeStream}} in each poll before. When {{ListShards}} fails from 
the start and keeps failing (the IAM role has no {{kinesis:ListShards}} 
permission, the stream name is wrong and Kinesis answers 
{{ResourceNotFoundException}}, or the calls are throttled for a long time), the 
list stays empty. Every poll then reads nothing and still ends as a successful 
poll: it calls {{forceConsumerAsReady()}} and the error counter stays 0. The 
consumer health check reports the consumer ready and UP, forever, while no 
record is read. The only sign is the WARN "Exception getting latest shard list" 
of the shard monitor. With a configured {{shardId}}, the poll logs that the 
shard is not in the list and returns 0, and the consumer is still seen ready.

With a configured {{shardId}}, a policy that grants {{kinesis:DescribeStream}} 
but not {{kinesis:ListShards}} made the polls fail before CAMEL-24197; now that 
consumer stops reading in silence. {{Kinesis2ConsumerHealthCheckStaticCredsIT}} 
expects readiness DOWN for a stream that does not exist; it passes only because 
it checks before the first poll.

The same happens for a short time when the first {{ListShards}} takes longer 
than the initial delay of the poll: the first poll reads an empty list and 
makes the consumer ready.

h3. How to reproduce

A consumer with a mocked {{KinesisClient}} whose {{listShards}} always throws 
{{AccessDeniedException}}: after a few polls {{getRecords}} was never called, 
the error counter is 0, and the readiness check of 
{{ScheduledPollConsumerHealthCheck}} is UP. Found with a TLA+ model of the 
shard monitor, the poll and the health check, and reproduced against the real 
consumer.

h3. Fix

The shard monitor keeps the error of its last {{ListShards}} (cleared when a 
{{ListShards}} returns). While no shard has been listed, a poll fails with an 
{{IllegalStateException}} whose cause is that error, so the error counter, the 
consumer health check (a readiness check: DOWN, with the error) and the 
back-off options work as for any failed poll; without an error yet (the first 
{{ListShards}} is still running) the poll returns 0. {{isConsumerReady()}} is 
false until the shards have been listed. Once listed, nothing changes: a later 
{{ListShards}} failure keeps the consumer reading the shards it knows, and it 
stays UP.

Not changed here: a {{ListShards}} call of the async client waits without a 
timeout, and an {{Error}} thrown in a run of the shard monitor stops it for 
good (reported separately).

_Filed with Claude Code on behalf of allthingssecurity._



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to