Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sporadic dead loop while WritePointsAsync to multiple destination #453

Open
Nick135 opened this issue Jan 15, 2023 · 1 comment
Open

Sporadic dead loop while WritePointsAsync to multiple destination #453

Nick135 opened this issue Jan 15, 2023 · 1 comment

Comments

@Nick135
Copy link

Nick135 commented Jan 15, 2023

I currently have three instances of a console application running, which collects different sensor data and sends it to an InfluxDB database. So far this works quite well.
Now I would like to send the sensor data of each console application to two different databases for testing purposes. After one to three hours at least one instance of WritePointsAsync gets stuck with 100% CPU utilization (of one core). The console application itself lives on and also receives sensor data.
The other two console applications continue to run until they also go into the endless loop.

Steps to reproduce:

  1. create two instances of the InfluxDBClient to two different destination
  2. continuous write to both destinations at the same time
  3. Wait for WritePointsAsync will not end

Expected behavior:
Send data to both DBs.

Actual behavior:
InfluxDBClient hang in infinite loop.

Specifications:

  • Client Version: Start test with v4.3; Problem still exits on v4.9
  • InfluxDB Version: InfluxDB v2.6
  • Platform: Windows 10 x64 .Net Framework

Example

influxDBClient = new List<InfluxDBClient>();
foreach (var url in settings.Url.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries))
{
	var clientOptions = new InfluxDBClientOptions.Builder()
		.Url(url)
		.AuthenticateToken(settings.Token.ToCharArray())
		.Org(settings.Organization)
		.Bucket(settings.Bucket)
		.Build();
	influxDBClient.Add(new InfluxDBClient(clientOptions));
}

while(!end)
{
	...
	Parallel.ForEach(influxDBClient,
	client =>
	{
		if (!client.GetWriteApiAsync().WritePointsAsync(values).ContinueWith(ee =>
		{
			if (ee.IsFaulted)
			{
				var ex = ee.Exception.InnerException ?? ee.Exception;
				Log($"{ex.GetType().Name}: {ex.Message}");
				Log(ex, null, false);
			}
		}).Wait(SendTimeOut))
			Log($"TimeOut send to DB: DB={client} {swSend.Elapsed.TotalMinutes.ToString("0.##")}min", Logtype.Warning);
	});
	...
}

WritePointsAsync hangs, when output stops

2023-01-15T11:11:49.2223432+01:00 Write to DB: qValues.Count=29
2023-01-15T11:11:49.2263650+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:11:52.2303350+01:00 Write to DB: qValues.Count=32
2023-01-15T11:11:52.2343375+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:11:55.2383351+01:00 Write to DB: qValues.Count=30
2023-01-15T11:11:55.2413354+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:11:58.2463351+01:00 Write to DB: qValues.Count=26
2023-01-15T11:11:58.2503355+01:00 Remove from Queue: SendTime=0,005s
2023-01-15T11:12:01.2553352+01:00 Write to DB: qValues.Count=27
2023-01-15T11:12:01.2613348+01:00 Remove from Queue: SendTime=0,006s
2023-01-15T11:12:04.2633822+01:00 Write to DB: qValues.Count=30
2023-01-15T11:12:04.2673864+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:12:07.2703350+01:00 Write to DB: qValues.Count=27
2023-01-15T11:12:07.2743355+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:12:10.2783351+01:00 Write to DB: qValues.Count=26
2023-01-15T11:12:10.2823354+01:00 Remove from Queue: SendTime=0,004s
2023-01-15T11:12:13.2863351+01:00 Write to DB: qValues.Count=29

@Nick135
Copy link
Author

Nick135 commented Jan 27, 2023

Is there anything related to this that I can do to speed it up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant