influxdata / influxdata/influxdb-client-csharp
InfluxOSS writing data to bucket with retention period doesn't write data
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 377
- Forks
- 93
- Avg merge
- 9m
- Merged PRs (30d)
- 2
Description
I am attempting to write data to a bucket running in Influx OSS that is running inside docker (Macbook M2 Pro, Docker version: 24.0.5, Influx OSS Image Version: 2.7.1).
The WriteXXXAsyncWithIRestReponse() methods return a result that has the `IsSuccessful` returning `True`, but the status code is actually `NoContent` with no data actually written to the database.
Using a consistent inlux client and api configuration:
```
using var influxClient = new InfluxDBClient(
new InfluxDBClientOptions(configuration.Url)
{
Bucket = configuration.Bucket,
Org = configuration.Organisation,
Token = configuration.Token,
PointSettings = { DefaultTags = configuration.DefaultTags},
}
);
var api = influxClient.GetWriteApiAsync();
```
The first snippet is using the `WritePointsAsyncWithIRestResponse` which returns `NoContent`, but no data is written as below:
```
var response = await api.WritePointsAsyncWithIRestResponse(
metrics.Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)))
.ToList(),
configuration.Bucket,
configuration.Organisation
);
```
The second snippet is using the `WriteRecordsAsyncWithIRestResponse` with also returns `NoContent`, but no data is written as below:
```
var response = await api.WriteRecordsAsyncWithIRestResponse(
metrics.Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)))
.Select(x => x.ToLineProtocol()),
WritePrecision.Ms,
configuration.Bucket,
configuration.Organisation
);
```
To try and understand what was going wrong, I thought I would put togther a quick harness that calls the API using HTTP calls directly using [Flurl](https://flurl.dev/), which returns `NoContent` but the data is correctly written to the bucket:
```
var request = configuration
.Url
.WithHeader("Authorization", $"Token {configuration.Token}")
.WithHeader("Content-Type", "text/plain; charset=utf-8")
.WithHeader("Accept", "application/json")
.AppendPathSegment("/api/v2/write")
.SetQueryParam("org", configuration.Organisation)
.SetQueryParam("bucket", configuration.Bucket)
.SetQueryParam("precision", "ms");
using var response = await request.PostStringAsync(
string.Join("\n",
metrics
.Select(x => pointDataConverter(x, PointData.Measurement(configuration.MeasurementName)).ToLineProtocol()))
);
```
Through all three different scenarios the data that is been generated is not changing (the same callback is used to convert from my internal data structure to the influx PointData structure), but only the third case actually persists data.
I would have expected that the second and third scenarios would have the same outcome given they are both writing line protocol directly, but this is not the case.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start by reproducing the discrepancy with WritePointsAsyncWithIRestResponse and WriteRecordsAsyncWithIRestResponse using the stated Influx OSS Docker setup, then compare them with the direct /api/v2/write request. Check the returned status and whether data appears in the configured bucket with its retention period. Done means the client methods persist the same records as the direct request or clearly report why they do not.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100