ClickHouse / ClickHouse/clickhouse-cs

ClickHouseRawResult.ReadAsStringAsync (and friends) should support cancellation

Open
#546 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
C#
Stars
94
Forks
22
Avg merge
11h 26m
Merged PRs (30d)
22

Description

### Use case

I want to be able to cancel calls like `rawResult.ReadAsStringAsync()`.

### Describe the solution you'd like

The usual: take an optional `CancellationToken` as a parameter:

```cs
var x = await rawResult.ReadAsStringAsync(cancellationToken)
```

This is not the case currently:

https://github.com/ClickHouse/clickhouse-cs/blob/dd51bfe82a03f0cd47bba74079d288ac8423d347/ClickHouse.Driver/ADO/Readers/ClickHouseRawResult.cs#L120-L124

Note: the cancellationToken passed to `ExecuteRawResultAsync` does not carry over to reads from the returned `ClickHouseRawResult`. Maybe the docs should warn about it.

### Workaround

Not ideal, but sometimes is acceptable.

```cs
var stream = await rawResult.ReadAsStreamAsync();
using (reader = new StreamReader(stream)) {
return await reader.ReadToEndAsync(cancellationToken)
}
```

Contributor guide

Open the contributing guide

Research direction

Start with ClickHouse.Driver/ADO/Readers/ClickHouseRawResult.cs at the referenced lines around ReadAsStringAsync, then inspect the related async read methods and ExecuteRawResultAsync. Confirm how cancellation is currently handled between execution and reads. Done means the relevant read methods accept an optional CancellationToken and the documentation addresses whether execution cancellation carries over.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.