ydb-platform / ydb-platform/ydb-python-sdk
bug: Transactional topic example exhausts producer_id limit with random IDs
@vgvoleg is already working on this.
Since Sep 17, 2026.
- Dominant language
- Python
- Stars
- 102
- Forks
- 75
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 13
Description
Bug Report
YDB Python SDK version:
Environment
Environment is irrelevant for reproduction - issue is in code example
Current behavior:
In the transactional topic write example (topic_transactions_async_example.py):
- Each call to
tx_writerwithout explicitproducer_idgenerates a new random producer_id - Transaction retries create additional producer_ids
- This rapidly consumes the producer_id limit (100K per 14 days)
- The example encourages production-unsafe usage patterns
Expected behavior:
Examples should demonstrate best practices:
- Explicit
producer_idshould be used to avoid random ID generation - Example should be resilient to transaction retries
- Should show either fixed producer_id or partition_id usage
- Should not risk exhausting producer_id limits in production scenarios
Steps to reproduce:
- Use example from
topic_transactions_async_example.py - Run
write_with_tx_examplemethod in a loop or with frequent retries - Observe rapid growth of producer_ids in the topic
Related code:
https://github.com/ydb-platform/ydb-python-sdk/blob/main/examples/topic/topic_transactions_async_example.py#L28
async def write_with_tx_example(driver: ydb.aio.Driver, topic: str, message_count: int = 10):
async with ydb.aio.QuerySessionPool(driver) as session_pool:
async def callee(tx: ydb.aio.QueryTxContext):
tx_writer: ydb.TopicTxWriterAsyncIO = driver.topic_client.tx_writer(tx, topic)
for i in range(message_count):
async with await tx.execute(query=f"select {i} as res;") as result_stream:
async for result_set in result_stream:
message = str(result_set.rows[0]["res"])
await tx_writer.write(ydb.TopicWriterMessage(message))
print(f"Message {result_set.rows[0]['res']} was written with tx.")
await session_pool.retry_tx_async(callee)
Other information:
Current example can exhaust 100K producer_id limit under moderate load
Possible Solutions
Fixed producer_id
Explicit partition selection
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.