Google-cloud-php: Memory leak when i use the Firestore set document

Created on 24 Jul 2019  路  6Comments  路  Source: googleapis/google-cloud-php

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

firestore p1 bug

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

highstrike picture highstrike  路  5Comments

lorenzosfarra picture lorenzosfarra  路  7Comments

lakano picture lakano  路  5Comments

joseph1125 picture joseph1125  路  8Comments

dwsupplee picture dwsupplee  路  7Comments