Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: DynamoDB stream not persisted completely #12149

Open
@BorisNaguet

Description

@BorisNaguet

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Dear,

I use Localstack very simply to create a table, configure a DynamoDB stream with the awslocal CLI, and listen to changes on that stream.
When I stop/start localstack, describing the table shows it has stream, but listing the streams returns an empty stream.

Regards

Expected Behavior

list-streams response is persisted

How are you starting LocalStack?

With the localstack script

Steps To Reproduce

Steps to reproduce:

  • using Windows + WSL + Podman

I have the following config in my default.env:

PERSISTENCE=1
SNAPSHOT_SAVE_STRATEGY=SCHEDULED
$ localstack --version
LocalStack CLI 4.0.0

Image:

Name | docker.io/localstack/localstack
Tag | latest
ID | sha256:cc82958a136d29e66baf620377f6c83b77096cab78c56569e6229836e6bb119a

1- create table + stream:

$ awslocal dynamodb create-table \
    --table-name FlightLeg \
    --attribute-definitions \
        AttributeName=FlightNumber,AttributeType=S \
        AttributeName=LegNumber,AttributeType=N \
    --key-schema \
        AttributeName=FlightNumber,KeyType=HASH \
        AttributeName=LegNumber,KeyType=RANGE \
    --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5

awslocal dynamodb update-table \
    --table-name FlightLeg \
    --stream-specification StreamEnabled=true,StreamViewType=NEW_AND_OLD_IMAGES

2- get status:

$ awslocal dynamodb describe-table --table-name FlightLeg
{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "FlightNumber",
                "AttributeType": "S"
            },
            {
                "AttributeName": "LegNumber",
                "AttributeType": "N"
            }
        ],
        "TableName": "FlightLeg",
        "KeySchema": [
            {
                "AttributeName": "FlightNumber",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "LegNumber",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": 1737388393.527,
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": 0.0,
            "LastDecreaseDateTime": 0.0,
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:eu-west-1:000000000000:table/FlightLeg",
        "TableId": "473c4a8d-0c08-4b22-852b-92080f266fef",
        "StreamSpecification": {
            "StreamEnabled": true,
            "StreamViewType": "NEW_AND_OLD_IMAGES"
        },
        "LatestStreamLabel": "2025-01-20T15:59:53.938",
        "LatestStreamArn": "arn:aws:dynamodb:eu-west-1:000000000000:table/FlightLeg/stream/2025-01-20T15:59:53.938",
        "DeletionProtectionEnabled": false
    }
}

$ awslocal dynamodbstreams list-streams
{
    "Streams": [
        {
            "StreamArn": "arn:aws:dynamodb:eu-west-1:000000000000:table/FlightLeg/stream/2025-01-20T15:59:53.938",
            "TableName": "FlightLeg",
            "StreamLabel": "2025-01-20T15:59:53.938"
        }
    ]
}

3- restart localstack

$ localstack restart
LocalStack restarted within the container.

4- Describe table OK

$ awslocal dynamodb describe-table --table-name FlightLeg
{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "FlightNumber",
                "AttributeType": "S"
            },
            {
                "AttributeName": "LegNumber",
                "AttributeType": "N"
            }
        ],
        "TableName": "FlightLeg",
        "KeySchema": [
            {
                "AttributeName": "FlightNumber",
                "KeyType": "HASH"
            },
            {
                "AttributeName": "LegNumber",
                "KeyType": "RANGE"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": 1737388393.527,
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": 0.0,
            "LastDecreaseDateTime": 0.0,
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 5,
            "WriteCapacityUnits": 5
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:eu-west-1:000000000000:table/FlightLeg",
        "StreamSpecification": {
            "StreamEnabled": true,
            "StreamViewType": "NEW_AND_OLD_IMAGES"
        },
        "LatestStreamLabel": "2025-01-20T15:59:53.938",
        "LatestStreamArn": "arn:aws:dynamodb:eu-west-1:000000000000:table/FlightLeg/stream/2025-01-20T15:59:53.938",
        "DeletionProtectionEnabled": false
    }
}

5- List stream empty

$ awslocal dynamodbstreams list-streams
{
    "Streams": []
}

The issue is that you can't directly add the stream as we get in an inconsistent state.

Environment

- OS: Windows + WSL + Podman
- LocalStack:
  LocalStack Docker image sha: sha256:cc82958a136d29e66baf620377f6c83b77096cab78c56569e6229836e6bb119a
 LocalStack version: 4.0.4.dev92
 LocalStack build date: 2025-01-08
 LocalStack build git hash: 243a4be82

Anything else?

No response

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