influxdb-client-csharp: The library hangs on the Flush method

I tried to upload many records via WriteAPI. When I try to send to many records (10000-100000) they are doesn’t be received all. When I try to split to 1000 records per request the library hangs on Flush method. If I doesn’t use Flush before disposing WriteAPI some data is lost.

The sample code:

            var start = 0;
            for (;;)
            {
                var historyBars = bars.Skip(start).Take(MaxBarsPerRequest).ToArray();
                if (historyBars.Length == 0)
                {
                    return;
                }
                if (start != 0)
                    await Task.Delay(100, token);
                start += MaxBarsPerRequest;
                m_logger.LogDebug(
                    $"Write bars for {historyBars.First().Security}. From: {historyBars.First().Date}, To: {historyBars.Last().Date}");
                using var api = m_client.GetWriteApi();
                api.WriteMeasurements(HistoryBarConstant.Bucket, HistoryBarConstant.OrgId, WritePrecision.S,
                    historyBars);
                //api.Flush();
            }

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 33 (12 by maintainers)

Most upvoted comments

I modified code to this and now it’s works fine for me 2020-04-20_1325

PS. The exceptions are not from this part. .