Ostico / PhpOrient

PhpOrient - Official Php driver based on the binary protocol of OrientDB.
Other
68 stars 37 forks source link

Allowed memory size exhausted (continued) #44

Closed andreyvk closed 7 years ago

andreyvk commented 8 years ago

Hi @Ostico

I've come across this error again trying to read not more than 10 records from a database

 PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 520093696 bytes) in /home/ubuntu/shared/www/app/lib/vendor/ostico/phporient/src/PhpOrient/Protocols/Binary/OrientSocket.php on line 138

I've put some error logging in the OrientSocket::read function and found out that at some point library was trying to read 520093695 bytes (I printed out the $size variable)!

Could you please help me debug this issue? Do you have any idea what could go wrong?

Ostico commented 8 years ago

Hi @andreyvk, This can be a bag dued to a particular record that is not well parsed by the driver.

You have something particular in your records? Can you provide some records as example or a way to reproduce the issue?

andreyvk commented 8 years ago

I see.

Could it be related to the fact that I have an error trying to do a simple query on that class in Orient Studio.

I'll try to extract data from the database and will send you a link.

Ostico commented 8 years ago

Thank you

andreyvk commented 8 years ago

Btw, my records are complex. I have all kinds of embedded stuff in there + graph edges

andreyvk commented 8 years ago

@Ostico is there any private email or chat room that I can exchange database details with you? I've removed a lot of stuff from the db, leaving the part that does not work. I'd like to send it to you with all the details, if possible

Ostico commented 8 years ago

I sent you

andreyvk commented 8 years ago

Hi @Ostico,

After I sent you my db and problem details did you have any time to look at the issue? Thanks in advance

Ostico commented 8 years ago

Hi @andreyvk,

Sorry, but i'm out for the entire week-end, untill Wednesday. Surely i can say to you something at the end of next week.

andreyvk commented 8 years ago

Ok thanks! I just need to know. Hope hearing from you sooner than later though :)))

pentium10 commented 8 years ago

@Ostico it's been several weeks since that, were you able to apply a fix to the problem, it's happening on our prod db too, and we require a fix. Issue #55 might be related to this one too.

Ostico commented 8 years ago

@pentium10 , sorry but until i can't reproduce the issue i can't fix it

andreyvk commented 7 years ago

Hi @Ostico,

Seems like this one is no longer an issue. Thanks for the help anyway!

steve-tapgen commented 7 years ago

I'm constantly getting out of memory exceptions when trying to dbOpen. I've even tried to delete + using the sample code to create a new DB named animals, still gives me the same exception ..

Allowed memory size of 67108864 bytes exhausted (tried to allocate 824191075 bytes) in /PhpOrient/Protocols/Binary/OrientSocket.php on line 141

If I increase my PHP memory (Shouldn't have to be so high) to for example 4000M, it then gives me a SocketException Uncaught exception 'PhpOrient\Exceptions\SocketException' with message 'socket_read(): unable to read from socket [104]: Connection reset by peer

Any help would be appreciated, am at my last straw before I switch to a different graph db I can't debug this any longer.

andreyvk commented 7 years ago

@steve-tapgen What is your OrientDB version?

steve-tapgen commented 7 years ago

Version 2.2.21

andreyvk commented 7 years ago

@steve-tapgen Can you plz provide more info on what's been queried. Possibly build a test case. Otherwise it's difficult or near to impossible to reproduce. I'll reopen the issue now.

steve-tapgen commented 7 years ago

Here's some sample code, it gets the out of memory exception on dbOpen .. (dbList works fine).

I'm running it like this: /usr/bin/php -d memory_limit=64M /var/www/html/test.php

test.php: ` require DIR . "/PhpOrient/vendor/autoload.php"; use PhpOrient\PhpOrient;

$client = new PhpOrient(); $client->hostname = 'ip-XXX-XXX-XXX-XXX.us-xxxx-x.compute.internal'; $client->port = 2424; $client->username = 'root'; $client->password = 'OURPASSWORD'; $client->connect();

$client->dbCreate( 'animals', PhpOrient::STORAGE_TYPE_MEMORY );

// error occurs on dbOpen $client->dbOpen( 'animals', 'admin', 'admin' );

// doesn't get here $client->command( 'create class Animal extends V' ); $client->command( "insert into Animal set name = 'rat', specie = 'rodent'" ); $animal = $client->query( "select * from Animal" ); `

andreyvk commented 7 years ago

@steve-tapgen I've tried your code specifically on 2.2.21 with PHP memory limit set to 64M. All looks good to me. The only difference is that my test was local. Is there any chance you could do a localhost test as well?

steve-tapgen commented 7 years ago

Ok it's working now (after testing locally + then remote).

The issue can be duplicated when using ioncube encoder on the php (cannot encrypt this PHP it must corrupt something). It's strange I've never had issues before with encrypting other PHPs.

Solution - if using ioncube do a --copy on PhpOrient so it doesn't encrypt it. It would be nice if it worked however but this will suffice for now! Thanks!

andreyvk commented 7 years ago

Np. Glad it worked out )) Closing the issue then. Cheers