@@ -65,7 +65,7 @@ async def callee(tx: ydb.aio.QueryTxContext):
6565 with pytest .raises (asyncio .TimeoutError ):
6666 await wait_for (topic_reader .receive_message (), 0.1 )
6767
68- async def test_no_msg_writter_in_error_case (
68+ async def test_no_msg_written_in_error_case (
6969 self , driver : ydb .aio .Driver , topic_path , topic_reader : ydb .TopicReaderAsyncIO
7070 ):
7171 async with ydb .aio .QuerySessionPool (driver ) as pool :
@@ -82,6 +82,29 @@ async def callee(tx: ydb.aio.QueryTxContext):
8282 with pytest .raises (asyncio .TimeoutError ):
8383 await wait_for (topic_reader .receive_message (), 0.1 )
8484
85+ async def test_msg_written_exactly_once_with_retries (
86+ self , driver : ydb .aio .Driver , topic_path , topic_reader : ydb .TopicReaderAsyncIO
87+ ):
88+ error_raised = False
89+ async with ydb .aio .QuerySessionPool (driver ) as pool :
90+
91+ async def callee (tx : ydb .aio .QueryTxContext ):
92+ nonlocal error_raised
93+ tx_writer = driver .topic_client .tx_writer (tx , topic_path )
94+ await tx_writer .write (ydb .TopicWriterMessage (data = "123" .encode ()))
95+
96+ if not error_raised :
97+ error_raised = True
98+ raise ydb .issues .Unavailable ("some retriable error" )
99+
100+ await pool .retry_tx_async (callee )
101+
102+ msg = await wait_for (topic_reader .receive_message (), 0.1 )
103+ assert msg .data .decode () == "123"
104+
105+ with pytest .raises (asyncio .TimeoutError ):
106+ await wait_for (topic_reader .receive_message (), 0.1 )
107+
85108
86109class TestTopicTransactionalWriterSync :
87110 def test_commit (self , driver_sync : ydb .Driver , topic_path , topic_reader_sync : ydb .TopicReader ):
@@ -110,7 +133,7 @@ def callee(tx: ydb.QueryTxContext):
110133 with pytest .raises (TimeoutError ):
111134 topic_reader_sync .receive_message (timeout = 0.1 )
112135
113- def test_no_msg_writter_in_error_case (
136+ def test_no_msg_written_in_error_case (
114137 self , driver_sync : ydb .Driver , topic_path , topic_reader_sync : ydb .TopicReaderAsyncIO
115138 ):
116139 with ydb .QuerySessionPool (driver_sync ) as pool :
0 commit comments