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

memory leak when repeatedly connecting while using HTTPS #137

Open
Kveri opened this issue Dec 28, 2022 · 2 comments
Open

memory leak when repeatedly connecting while using HTTPS #137

Kveri opened this issue Dec 28, 2022 · 2 comments

Comments

@Kveri
Copy link

Kveri commented Dec 28, 2022

Steps to reproduce:

<?php
require_once('vendor/autoload.php');

use InfluxDB2\Client;
use InfluxDB2\Model\WritePrecision;
use InfluxDB2\Point;

$token = 'token';
$org = 'Home';
$bucket = 'default';

while (1) {
  $client = new Client([
    "url" => "https://influx:8086",
    "token" => $token,
  ]);


  $dataArray = ['name' => 'test',
    'fields' => array('xxx' => 123),
  ];

  $writeApi = $client->createWriteApi();
  $writeApi->write($dataArray, WritePrecision::MS, $bucket, $org);

  $writeApi->close();
  unset($writeApi);
  unset($dataArray);
  $client->close();
  unset($client);
}

Expected behavior:
Memory usage doesn't increase that heavily.

Actual behavior:
Memory usage does increase heavily. I dumped the memory, it seems to be related to CA certificates. I was able to find thousands of instances of each CA certificate in php memory.

Also I get this error after 10-20 seconds:

PHP Fatal error:  Uncaught Http\Client\Exception\RequestException: error setting certificate file: /etc/ssl/certs/ca-certificates.crt in /home/kveri/goodwe/vendor/php-http/curl-client/src/Client.php:166
Stack trace:
#0 /home/kveri/goodwe/vendor/php-http/client-common/src/PluginClient.php(81): Http\Client\Curl\Client->sendRequest()
#1 /home/kveri/goodwe/vendor/php-http/client-common/src/Plugin/RedirectPlugin.php(175): Http\Client\Common\PluginClient->Http\Client\Common\{closure}()
#2 /home/kveri/goodwe/vendor/php-http/client-common/src/PluginChain.php(46): Http\Client\Common\Plugin\RedirectPlugin->handleRequest()
#3 /home/kveri/goodwe/vendor/php-http/client-common/src/Plugin/HeaderDefaultsPlugin.php(44): Http\Client\Common\PluginChain->Http\Client\Common\{closure}()
#4 /home/kveri/goodwe/vendor/php-http/client-common/src/PluginChain.php(46): Http\Client\Common\Plugin\HeaderDefaultsPlugin->handleRequest()
#5 /home/kveri/goodwe/vendor/php-http/client-common/src/PluginChain.php(61): Http\Client\Common\PluginChain->Http\Client\Common\{closure}()
#6 /home/kveri/goodwe/vendor/php-http/client-common/src/PluginClient.php(87): Http\Client\Common\PluginChain->__invoke()
#7 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php(151): Http\Client\Common\PluginClient->sendRequest()
#8 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php(214): InfluxDB2\DefaultApi->sendRequest()
#9 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php(79): InfluxDB2\DefaultApi->request()
#10 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(145): InfluxDB2\DefaultApi->post()
#11 [internal function]: InfluxDB2\WriteApi->InfluxDB2\{closure}()
#12 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteRetry.php(70): call_user_func()
#13 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(146): InfluxDB2\WriteRetry->retry()
#14 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(86): InfluxDB2\WriteApi->writeRaw()
#15 /home/kveri/goodwe/xxx.php(24): InfluxDB2\WriteApi->write()
#16 {main}

Next InfluxDB2\ApiException: [0] error setting certificate file: /etc/ssl/certs/ca-certificates.crt in /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php:179
Stack trace:
#0 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php(214): InfluxDB2\DefaultApi->sendRequest()
#1 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php(79): InfluxDB2\DefaultApi->request()
#2 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(145): InfluxDB2\DefaultApi->post()
#3 [internal function]: InfluxDB2\WriteApi->InfluxDB2\{closure}()
#4 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteRetry.php(70): call_user_func()
#5 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(146): InfluxDB2\WriteRetry->retry()
#6 /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/WriteApi.php(86): InfluxDB2\WriteApi->writeRaw()
#7 /home/kveri/goodwe/xxx.php(24): InfluxDB2\WriteApi->write()
#8 {main}
  thrown in /home/kveri/goodwe/vendor/influxdata/influxdb-client-php/src/InfluxDB2/DefaultApi.php on line 179

Specifications:

  • Client Version: 3.2.0
  • InfluxDB Version: 2.6.0
  • Platform: x86_64 ubuntu
@Kveri Kveri changed the title memory leak memory leak when repeatedly connecting while using HTTPS Dec 28, 2022
@bednar
Copy link
Contributor

bednar commented Dec 28, 2022

Hi @Kveri,

thanks for using our client.

Does the /etc/ssl/certs/ca-certificates.crt contains valid CA certificates?

For more info see:

Regards

@Kveri
Copy link
Author

Kveri commented Dec 28, 2022

Hi @Kveri,

thanks for using our client.

Does the /etc/ssl/certs/ca-certificates.crt contains valid CA certificates?

For more info see:

Regards

yes, all of them are valid. I checked them using openssl x509 -in -noout -text. It's standard ubuntu distribution CA list + one CA cert added for my local CA.

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

2 participants