Skip to content

Commit 10aac80

Browse files
feat: invoke ReadAsync() on CloseAsync & dev: refactoring CHANGELOG.md (#275)
1 parent 505f804 commit 10aac80

File tree

3 files changed

+137
-70
lines changed

3 files changed

+137
-70
lines changed

CHANGELOG.md

Lines changed: 115 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,68 @@
1+
- Fixed: YdbDataReader does not throw YdbException when CloseAsync is called for UPDATE/INSERT statements with no
2+
result.
3+
14
## v0.14.0
2-
* Reader client for YDB topics
3-
* Fixed: send PartitionIds in InitRequest.
4-
* Do a committed offset on StopPartitionSessionRequest event anyway.
5-
* Added log info on StopPartitionSessionRequest event.
6-
* PartitioningSettings were changed to change the PartitionCountLimit to MaxActivePartitions.
7-
* Dev: updated System.IdentityModel.Tokens.Jwt from version 0.7.0 to version 8.5.0.
8-
* PartitionSession.Stop uses committedOffset to complete commit tasks.
9-
* Changed batch type: IReadOnlyCollection<Message<TValue>> -> IReadOnlyList<Message<TValue>>.
10-
* Invoking TryReadRequestBytes before deserializing message.
11-
* Updated Ydb.Protos 1.0.6 -> 1.1.1: Updated version of the Grpc.Net.Client library to 2.67.0 and proto messages.
12-
* Fixed: YdbDataReader.GetDataTypeName for optional values.
13-
* Added support for "Columns" collectionName in YdbConnection.GetSchema(Async).
5+
6+
- Reader client for YDB topics
7+
- Fixed: send PartitionIds in InitRequest.
8+
- Do a committed offset on StopPartitionSessionRequest event anyway.
9+
- Added log info on StopPartitionSessionRequest event.
10+
- PartitioningSettings were changed to change the PartitionCountLimit to MaxActivePartitions.
11+
- Dev: updated System.IdentityModel.Tokens.Jwt from version 0.7.0 to version 8.5.0.
12+
- PartitionSession.Stop uses committedOffset to complete commit tasks.
13+
- Changed batch type: IReadOnlyCollection<Message<TValue>> -> IReadOnlyList<Message<TValue>>.
14+
- Invoking TryReadRequestBytes before deserializing message.
15+
- Updated Ydb.Protos 1.0.6 -> 1.1.1: Updated version of the Grpc.Net.Client library to 2.67.0 and proto messages.
16+
- Fixed: YdbDataReader.GetDataTypeName for optional values.
17+
- Added support for "Columns" collectionName in YdbConnection.GetSchema(Async).
1418

1519
## v0.12.0
16-
* GetUint64(int ordinal) returns a ulong for Uint8, Uint16, Uint32, Uint64 YDB types.
17-
* GetInt64(int ordinal) returns a int for Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32 YDB types.
18-
* GetUint32(int ordinal) returns a uint for Uint8, Uint16, Uint32 YDB types.
19-
* GetInt32(int ordinal) returns a int for Int8, Int16, Int32, Uint8, Uint16 YDB types.
20-
* GetUint16(int ordinal) returns a ushort for Uint8, Uint16 YDB types.
21-
* GetInt16(int ordinal) returns a short for Int8, Int16, Uint8 YDB types.
22-
* GetDouble(int ordinal) returns a double for Float and Double YDB types.
23-
* Throw InvalidCastException on string.Empty in `GetChar(int ordinal)`.
24-
* Changed Ydb.Sdk.Value.InvalidTypeException to InvalidCastException in YdbValueParser.
25-
* Changed InvalidCastException to InvalidOperationException in YdbParameter.
26-
* Added specification tests: YdbCommandTests and YdbParameterTests.
27-
* YdbConnection.Database returns string.Empty if ConnectionStringBuilder is null.
28-
* Propagated cancellationToken in Execute[.*]Async methods.
29-
* When YdbCommand has an open data reader, it throws InvalidOperationException on the setters: CommandText, DbConnection.
30-
* Added checkers to YdbCommand.Prepare().
31-
* CommandText getter doesn't throw an exception if the CommandText property has not been initialized.
20+
21+
- GetUint64(int ordinal) returns a ulong for Uint8, Uint16, Uint32, Uint64 YDB types.
22+
- GetInt64(int ordinal) returns a int for Int8, Int16, Int32, Int64, Uint8, Uint16, Uint32 YDB types.
23+
- GetUint32(int ordinal) returns a uint for Uint8, Uint16, Uint32 YDB types.
24+
- GetInt32(int ordinal) returns a int for Int8, Int16, Int32, Uint8, Uint16 YDB types.
25+
- GetUint16(int ordinal) returns a ushort for Uint8, Uint16 YDB types.
26+
- GetInt16(int ordinal) returns a short for Int8, Int16, Uint8 YDB types.
27+
- GetDouble(int ordinal) returns a double for Float and Double YDB types.
28+
- Throw InvalidCastException on string.Empty in `GetChar(int ordinal)`.
29+
- Changed Ydb.Sdk.Value.InvalidTypeException to InvalidCastException in YdbValueParser.
30+
- Changed InvalidCastException to InvalidOperationException in YdbParameter.
31+
- Added specification tests: YdbCommandTests and YdbParameterTests.
32+
- YdbConnection.Database returns string.Empty if ConnectionStringBuilder is null.
33+
- Propagated cancellationToken in Execute[.*]Async methods.
34+
- When YdbCommand has an open data reader, it throws InvalidOperationException on the setters: CommandText,
35+
DbConnection.
36+
- Added checkers to YdbCommand.Prepare().
37+
- CommandText getter doesn't throw an exception if the CommandText property has not been initialized.
3238

3339
## v0.11.0
34-
* Fix bug: GetValue(int ordinal) return DBNull.Value if fetched NULL value.
35-
* Fix: NextResult() moves to the next result and skip the first ResultSet.
36-
* Added specification DbDataReaderTests.
37-
* If dataOffset is larger than the length of data, GetChars and GetBytes methods will return 0.
38-
* If YdbDataReader is closed: `throw new InvalidOperationException("The reader is closed")`.
39-
* InvalidOperationException on ConnectionString property has not been initialized.
40-
* One YdbTransaction per YdbConnection. Otherwise, throw an exception: InvalidOperationException("A transaction is already in progress; nested/concurrent transactions aren't supported.").
41-
* ConnectionString returns an empty.String when it is not set.
42-
* When a YdbDataReader is closed, if stream is not empty, a YdbTransaction fails if it is not null. A session also fails due to a possible error SessionBusy race condition with the server.
43-
* Fixed bug: Fetch txId from the last result set.
44-
* YdbTransaction CheckDisposed() (invoke rollback if transaction hasn't been committed).
45-
* Dev: Added specification tests for YdbTransaction.
40+
41+
- Fix bug: GetValue(int ordinal) return DBNull.Value if fetched NULL value.
42+
- Fix: NextResult() moves to the next result and skip the first ResultSet.
43+
- Added specification DbDataReaderTests.
44+
- If dataOffset is larger than the length of data, GetChars and GetBytes methods will return 0.
45+
- If YdbDataReader is closed: `throw new InvalidOperationException("The reader is closed")`.
46+
- InvalidOperationException on ConnectionString property has not been initialized.
47+
- One YdbTransaction per YdbConnection. Otherwise, throw an exception: InvalidOperationException("A transaction is
48+
already in progress; nested/concurrent transactions aren't supported.").
49+
- ConnectionString returns an empty.String when it is not set.
50+
- When a YdbDataReader is closed, if stream is not empty, a YdbTransaction fails if it is not null. A session also fails
51+
due to a possible error SessionBusy race condition with the server.
52+
- Fixed bug: Fetch txId from the last result set.
53+
- YdbTransaction CheckDisposed() (invoke rollback if transaction hasn't been committed).
54+
- Dev: Added specification tests for YdbTransaction.
4655

4756
## v0.10.0
48-
- Fixed bug in Topic Writer: race condition when session fails, then write operation starts on previous session and new session is created. Messages may be lost.
49-
- Supported in ADO.NET GetSchema(Async). CollectionNames:
50-
* Tables
51-
* TablesWithCollections
52-
* DataSourceInformation
53-
* MetaDataCollections
54-
* Restrictions
57+
58+
- Fixed bug in Topic Writer: race condition when session fails, then write operation starts on previous session and new
59+
session is created. Messages may be lost.
60+
- Supported in ADO.NET GetSchema(Async). CollectionNames:
61+
* Tables
62+
* TablesWithCollections
63+
* DataSourceInformation
64+
* MetaDataCollections
65+
* Restrictions
5566
- Rename field _onStatus -> _onNotSuccessStatus in YdbDataReader
5667
- If session is not active, do not invoke DeleteNotActiveSession(session)
5768
- AttachStream: connect stream using NodeId
@@ -60,6 +71,7 @@
6071
- DbConnection.Session.OnStatus(status) in YdbTransaction
6172

6273
## v0.9.4
74+
6375
- Do not pessimize the node on Grpc.Core.StatusCode.Cancelled and Grpc.Core.StatusCode.DeadlineExceeded.
6476
- Dispose of WriterSession using dispose CancellationToken.
6577
- BidirectionalStream is internal class.
@@ -68,124 +80,159 @@
6880
- Cancel writing tasks after disposing of Writer.
6981

7082
## v0.9.3
83+
7184
- Fixed bug in Topic Writer: worker is stopped by disposeCts
72-
- Fixed bug in sql parser ADO.NET: deduplication declare param in YQL query
85+
- Fixed bug in sql parser ADO.NET: deduplication declare param in YQL query
7386
- Deleted property BufferOverflowRetryTimeoutMs
7487

7588
## v0.9.2
89+
7690
- Fixed bug: delete deadline grpc timeout on AttachStream
7791

7892
## v0.9.1
93+
7994
- Update log level on AttachStream
8095

8196
## v0.9.0
97+
8298
- Writer client for YDB topics
83-
- Fixed bug: delete default timeout grpc.deadline
99+
- Fixed bug: delete default timeout grpc.deadline
84100

85101
## v0.9.0-rc1
102+
86103
- Topic Writer updated release candidate:
87-
* Do not send messages that have a timeout by cancelToken.
88-
* If your value serializer throws an exception, this will be wrapped in a WriterException with unspecified status.
89-
* Added BufferOverflowRetryTimeoutMs to the next try write.
90-
* Rename _disposeTokenSource -> _disposeCts.
91-
* Optimize write worker: if (_toSendBuffer.IsEmpty) continue.
92-
* On RPC errors create DummyWriterSession.
93-
* Message has been skipped because its sequence number is less than or equal to the last processed server's SeqNo.
94-
* Calculate the next sequence number from the calculated previous messages.
104+
* Do not send messages that have a timeout by cancelToken.
105+
* If your value serializer throws an exception, this will be wrapped in a WriterException with unspecified status.
106+
* Added BufferOverflowRetryTimeoutMs to the next try write.
107+
* Rename _disposeTokenSource -> _disposeCts.
108+
* Optimize write worker: if (_toSendBuffer.IsEmpty) continue.
109+
* On RPC errors create DummyWriterSession.
110+
* Message has been skipped because its sequence number is less than or equal to the last processed server's SeqNo.
111+
* Calculate the next sequence number from the calculated previous messages.
95112

96113
## v0.9.0-rc0
114+
97115
- Topic Writer release candidate:
98-
* Updated CAS semantics for enqueuing in the buffer.
99-
* Processed buffer overflow on WriteAsync.
100-
* Setting NotStartedWriterSession with a fail reason on RPC and more errors.
101-
* New initialization strategy for WriterSession (background task).
102-
* Supported cancellation token for sending tasks.
103-
* Fixed setting the SeqNo field in the message (in-flight buffer already has a seqNo) and added a check on canceled TCS.
104-
* Using BitConverter for Serializer / Deserializer.
105-
- Fixed: grpc requests go via proxy on Grpc.NET.Client >= 2.44
116+
* Updated CAS semantics for enqueuing in the buffer.
117+
* Processed buffer overflow on WriteAsync.
118+
* Setting NotStartedWriterSession with a fail reason on RPC and more errors.
119+
* New initialization strategy for WriterSession (background task).
120+
* Supported cancellation token for sending tasks.
121+
* Fixed setting the SeqNo field in the message (in-flight buffer already has a seqNo) and added a check on canceled
122+
TCS.
123+
* Using BitConverter for Serializer / Deserializer.
124+
- Fixed: grpc requests go via proxy on Grpc.NET.Client >= 2.44
106125

107126
## v0.8.0
108-
- Fixed bug on commit with fail, no set failed flag for rollback invocation
127+
128+
- Fixed bug on commit with fail, no set failed flag for rollback invocation
109129
- Supported UUID (Guid)
110130

111131
## v0.7.3
132+
112133
- Fixed YdbDataReader: extract Json / Yson types
113134

114135
## v0.7.2
136+
115137
- Fixed YdbDataReader: `GetValue()` returns `DbNull.Value` if field is null
116138
- YdbOperationInProgressException extends YdbException
117139

118140
## v0.7.1
141+
119142
- If an error happened in the transaction, allow one empty rollback
120143

121144
## v0.7.0
145+
122146
- Parsed @param then prepared for use with $ prefix (@p -> $p)
123147
- Fully integrated with Dapper
124148

125149
## v0.6.3
150+
126151
- Fixed bug: parameter type mismatch, when setting optional with null
127152

128153
## v0.6.2
154+
129155
- Fixed bug: adding correct placeholders to all logging calls with parameters
130156

131157
## v0.6.1
158+
132159
- Check status of the transport or server for an invalidated session
133160
- Fixed NPE in DescribeTable
134161

135162
## v0.6.0
163+
136164
- ADO.NET over query-service
137165
- Add EndpointPool
138166
- Add SessionPool 2.0
139167

140168
## v0.4.0
169+
141170
- Fix bug: rounding down when inserting a Timestamp YDB type
142171
- ChannelCache has been implemented using ChannelPool and EndpointPool
143172

144173
## v0.3.2
174+
145175
- Make KeepAlive method public for TableClient
146176

147177
## v0.3.1
178+
148179
- Fix error: Access denied without user token
149180

150181
## v0.3.0
182+
151183
- Add rollback transaction API
152184

153185
## v0.2.2
186+
154187
- Passed logger to TxControl.ToProto
155188

156189
## v0.2.1
190+
157191
- Retry discovery on driver initialize
158192

159193
## v0.2.0
194+
160195
- Added MakeTablePath, CopyTable, CopyTables, DescribeTable methods for TableClient
161196
- Add logging for transactions
162197

163198
## v0.1.5
199+
164200
- Fix timeout error on create session
165201
- Fix transport error on delete session
166202

167203
## v0.1.4
204+
168205
- Add exception throwing when results truncated
169206
- lint: add line feed at file end
170207

171208
## v0.1.3
209+
172210
- Add static auth
211+
173212
## v0.1.1
213+
174214
- Add static code analysis
175215
- Add CodeQL analysis
176216
- Add linter
177217
- Apply uniform code style and fix all warnings
218+
178219
## v0.1.0
220+
179221
- Add support of decimal type
222+
180223
## v0.0.9
224+
181225
- Remove support for .NET Core 3.1
182226
- Add support for .NET 7.0
183-
-
227+
-
228+
184229
## v0.0.8
230+
185231
- Fixed version number
186232

187233
## v0.0.6
188-
- Add methods for castion to c# nullable to YQL Optional
234+
235+
- Add methods for castion to c# nullable to YQL Optional
189236
- Add explicit cast operator for some types
190237
- Tests refactoring
191238
- Add Bool type support

src/Ydb.Sdk/src/Ado/YdbDataReader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,8 @@ public override async Task CloseAsync()
561561
return;
562562
}
563563

564+
var isConsumed = ReaderState == State.IsConsumed || (!await ReadAsync() && ReaderState == State.IsConsumed);
564565
ReaderMetadata = CloseMetadata.Instance;
565-
var isConsumed = ReaderState == State.IsConsumed;
566566
ReaderState = State.Close;
567567

568568
if (isConsumed)
@@ -595,7 +595,7 @@ private YdbValue GetFieldYdbValue(int ordinal)
595595
: ydbValue;
596596
}
597597

598-
private async Task<State> NextExecPart()
598+
private async ValueTask<State> NextExecPart()
599599
{
600600
try
601601
{

src/Ydb.Sdk/tests/Ado/YdbTransactionTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,26 @@ public void Rollback_WhenUpsertThenRollback_ReturnPrevRow()
4242
Assert.Equal(new DateTime(2008, 11, 21), ydbCommand.ExecuteScalar());
4343
}
4444

45+
[Fact]
46+
public void Commit_WhenUpdateWithYdbDataReader_ReturnUpdatedRow()
47+
{
48+
using var connection = CreateOpenConnection();
49+
var ydbTransaction = connection.BeginTransaction();
50+
var ydbCommand = new YdbCommand(connection)
51+
{
52+
CommandText = $@"UPDATE {Tables.Episodes} SET title=""test Episode 2""
53+
WHERE series_id = 2 AND season_id = 5 AND episode_id = 1;"
54+
};
55+
var executeReaderAsync = ydbCommand.ExecuteReader();
56+
executeReaderAsync.Close();
57+
ydbTransaction.Commit();
58+
Assert.Equal("test Episode 2", new YdbCommand(connection)
59+
{
60+
CommandText = $@"SELECT title FROM {Tables.Episodes}
61+
WHERE series_id = 2 AND season_id = 5 AND episode_id = 1;"
62+
}.ExecuteScalar());
63+
}
64+
4565
[Fact]
4666
public void Commit_WhenMakeTwoUpsertOperation_ReturnUpdatedTables()
4767
{

0 commit comments

Comments
 (0)