Skip to content

bug: Kinesis Subscriber returns SubscribeToShardEvent with invalid sequence number of 0 #10000

@fs-jasonc

Description

@fs-jasonc

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Behavior

When implementing a Subscriber<SubscribeToShardEventStream> using the AWS Java SDK, starting from a timestamp and inserting records, onNext returns a SubscribeToShardEvent with a continuationSequenceNumber of 0. The returned record sequenceNumbers are like:

49658026119490182770032252969867129256605616914593865986
49658026119490182770032252969868338182425231543768572162
49658026119490182770032252969869547108244846172943278338

Creating a new subscriber using this sequence number of 0 gives an error:
Unable to find record with provided SequenceNumber SequenceNumber(0) in stream

Localstack says:

localstack      | 2024-01-05T11:29:24.910  INFO --- [functhread10] l.s.k.kinesis_mock_server  : kinesis.mock.ResourceNotFoundException: Unable to find record with provided SequenceNumber SequenceNumber(0) in stream Some(state-store-test-stream-8e44ffd7-b8ea-4a8e-b78a-d64d3d95fb4e)

Expected Behavior

The continuationSequenceNumber should be the highest sequence number reached, not 0 (a non-existent record).

How are you starting LocalStack?

With a docker-compose file

Steps To Reproduce

  1. Create a Kinesis Stream
  2. Put records to it
  3. Subscribe to it. Read records (note 0 continuationSequenceNumber)
  4. Put more records
  5. Subscribe to it again, using position of AFTER_SEQUENCE_NUMBER of 0. Get error due to invalid sequence number.

Environment

- OS: Ubuntu
- LocalStack: 3.0.5
- Java AWS SDK: 2.21.37

Anything else?

Cause

ContinuationSequenceNumber is simply set to 0 and never updated when records are added:

https://github.com/localstack/localstack/blob/master/localstack/services/kinesis/provider.py#L136

In previous versions (eg 0.14.5) which worked, I think the number was derived from the records.

Versions

This wasn't in v0.14.5, but is in v3.0.5 and v2.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions