Hi,
I'm using the google/cloud-firestore(v1.6.2) library to save info in Firestore database.
The flow follows very well, but I'm problems with a memory leak, the memory of my Kubernetes pods does not stop to increase.
My implementation:
<?php
namespace App\Repositories\Modules\AccountLog\Save;
use Google\Cloud\Firestore\FirestoreClient;
use Arquivei\App\Workers\Modules\AccountLog\Save\Entities\Log;
use Arquivei\App\Workers\Modules\AccountLog\Save\Gateways\AccountLogStorageGateway;
class AccountLogRepository implements AccountLogStorageGateway
{
private $collection;
public function __construct()
{
$firestore = new FirestoreClient([
'projectId' => env('GOOGLE_STORAGE_PROJECT_ID'),
'keyFilePath' => env('GOOGLE_STORAGE_CREDENTIALS'),
]);
$collection = env('GOOGLE_FIRESTORE_COLLECTIONS_PREFIX', '') . 'account_logs';
$this->collection = $firestore->collection($collection);
}
public function storage(Log $log): void
{
$this->collection->document($log->getId())->set([
'account_id' => $log->getUser()->getAccountId(),
'user' => [
'name' => $log->getUser()->getName(),
'email' => $log->getUser()->getEmail(),
],
'is_system' => is_null($log->getUser()->getId()),
'ip' => $log->getIp(),
'url' => $log->getUrl(),
'extra' => $log->getExtra(),
'operation' => $log->getOperation(),
'created_at' => $log->getCreatedAt(),
]);
}
}
Pods memory
Image
Thanks for the report @ruschoni02! Would you be able to share a little more context about how requests are processed? If possible to share a dockerfile which would help me reproduce the issue, that would also be very helpful.
Of course @dwsupplee
I'm using this image arquivei/php:php7.3-cli-kafka
Docker file link
My flow is as follows
I have a worker who is consuming Kafka, he is an infinite loop. And every message consumed he inserts it into Firestore.
I deployed today saving to Firestore, and we started to have these memory leaks nonstop
Thanks, that's really helpful :).
Out of curiosity, if you disable the protobuf extension do you see any difference in memory usage?
I'll take this test and I'll answer you :D
@dwsupplee I disabled the protobuf extension and now the memory leak doesn't happen more :D
Thanks for checking, @ruschoni02. That definitely helps me narrow down what I need to look at.