I am testing write/query time series data to/from InfluxDB v2 using c#. Basically I used pretty much the example provided in the WebInterface under Data->"Load Data"->"Client Libraries"->C#.
I can write to the database no problem but when I try to query the data, I got the exception
'An item with the same key has already been added. Key: result'.
The call that causes the problem is
public async Task<List<InfluxDB.Client.Core.Flux.Domain.FluxTable>> QueryDB()
{
string bucket = "ABucket";
var query = $"from(bucket:\"{bucket}\") |> range(start: -1m)";
var tables = await client.GetQueryApi().QueryAsync(query, "MyOrganisation");
// client is an instance of InfluxDBClient
return tables;
}
This crashes when it returns from the QueryAsync call above.
I have read the other post 1 and post 2 with a similar problem but after going through those and checking my code, I did not see anything that is identically named. I even changed a bunch of names to make sure nothing is repeated. But the problem is not going away.
If I remove the async call that there is no problem but then I cannot query the database if I did that.
Has anyone used the c# example provided by InfluxDB and succeeded?
Here is the stacktrace if it is of any help.
at InfluxDB.Client.Core.Internal.AbstractQueryClient.<>c.<.cctor>b__22_1(Exception e)
at InfluxDB.Client.Core.Internal.AbstractQueryClient.<Query>d__9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult()
at InfluxDB.Client.QueryApi.<QueryAsync>d__7.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MainApp.InfluxDBControl.<QueryDB>d__12.MoveNext() in D:\Test\TestProject\TestInfluxDB\InfluxDBControl.cs:line 104
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at MainApp.MainTest.<CatchUpButton_Click>d__20.MoveNext() in D:\Test\TestProject\TestInfluxDB\MainAppForm.cs:line 171