Skip to content

Enabling Alternator streams on table with very long name crashes Scylla #24598

@nyh

Description

@nyh

Alternator limits table names to 222 characters, because a longer name would result in a directory name longer than 255 characters, and an IO failure - which potentially crashes.

However, when enabling Alternator Streams, a _scylla_cdc_log suffix (cdc_log_suffix in cdc/log.cc) is added to the table's name to create a new table. Unfortunately, if the resulting name is longer than 222 characters, today Scylla experiences an IO error and shuts down. Each of the the following two test shuts down Scylla today (both are added in test/alternator/test_streams.py in pull request #24597):

# When Alternator enables streams, CDC creates a new table whose name is the
# same as the existing table with the suffix "_scylla_cdc_log". Let's check
# that if the table's name is already as long as it can be, we can still
# enable streams without any disasterous I/O error.
# We have two versions of this test - one with the stream created with the
# table, and one with the stream added to the existing table.
# Reproduces #24598

def test_stream_table_name_length_222_create(dynamodb):
    with new_test_table(dynamodb, name=padded_name(222),
        Tags=TAGS,
        StreamSpecification={'StreamEnabled': True, 'StreamViewType': 'KEYS_ONLY'},
        KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' } ],
        AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' }, ]
    ) as table:
        pass

def test_stream_table_name_length_222_update(dynamodb):
    with new_test_table(dynamodb, name=padded_name(222),
        Tags=TAGS,
        KeySchema=[ { 'AttributeName': 'p', 'KeyType': 'HASH' } ],
        AttributeDefinitions=[ { 'AttributeName': 'p', 'AttributeType': 'S' }, ]
    ) as table:
        table.update(StreamSpecification={'StreamEnabled': True, 'StreamViewType': 'KEYS_ONLY'});
        # DynamoDB doesn't allow deleting the base table while the stream
        # is in the process of being added
        wait_for_active_stream(dynamodbstreams, table)

Scylla is shut down after the following message:

ERROR 2025-06-22 15:16:26,643 [shard 0: gms] raft - [8062f308-8b33-4e46-b740-0bc8fa473f50]
applier fiber stopped because of the error: std::_Nested_exception<raft::state_machine_error>
(State machine error at raft/server.cc:1369): storage_io_error (Storage I/O error: 36: filesystem error: 
mkdir failed: File name too long [/tmp/scylla-test-1565101/data/alternator_alternator_Test_1750594586633xxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx/alternator_Test_1750594586633xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

We need to fix this bug in one of two ways:

  1. If the table's name is too long, one will simply be unable to enable streams on it, but get a clean error - not a crash. We already do a similar thing for GSI/LSI: There the sum of table name and GSI/LSI name needs to be up to 221/220 and if it isn't, you just can't add that GSI/LSI.
  2. Reduce the table's name limitation from 222 to 207 or perhaps best - to 192 as was recently done in CQL - cql, schema: Extend keyspace, table, views, indexes name length limit from 48 to 192 bytes #24500. If the limit is reduced, it will surly be possible to add that suffix to any name.

I think I prefer option 2. It means that some extremely long table names which were possible in the current release will no longer be possible and docs/alternator/compatibility.md (added in #24597) will needs to be updated, but I don't think anyone would shed any tears. Users do not really use such extremely long names. But if we don't want to risk any type of backward incompatibility, then option 1 is a good option.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions