-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Can not load more than 1000 items using Phalcon-3.0.x + PHP-7.0 + PostgreSQL #12057
Comments
I tested with this sample code using PDO PHP-7.0 directly (with same configuration) public static function findAllDetails($id) {
$user = 'postgres';
$pass = 'mypassword';
$conn = new \PDO('pgsql:host=127.0.0.1; dbname=mydb;', $user, $pass);
$mainSQL = "SELECT * FROM mytable";
$sth = $conn->prepare($mainSQL);
$sth->setFetchMode(\PDO::FETCH_ASSOC);
$sth->execute();
$retRows = $sth->fetchAll();
var_dump($retRows);
unset($sth);
unset($conn);
} And it works showing all ~4000 items. And showing another resultset ~32000 items too without any problems. |
SOLVED Increase php.ini memory_limit solving my problem |
Actually as far as i know there is still small memory leak on php 7 and phalcon 3.0.0 which can happen especially on big results. |
@Jurigag yes i guess so @sergeyklay @andresgutierrez I hope it won't become a bigger problem |
Yeah, what was your memory_limit and what is now after being increased? |
@andresgutierrez my initial memory_limit was 128M (default setting from php ubuntu repo installation). I increased to 2048M, and it was working then. Initial memory_limit 128M was enough using PHP-5.6 + Phalcon-2.1.x (latest build) to run my function. |
That's strange, I'll check if there are memory leaks we haven't aware of |
I set 128M not working Thank you. That's quite big memory. |
Were you trying what i posted many times - Adding getters and setters to models as well all properties to them ? |
But you checked this latest committ to 3.0.x ? Well the best could be if you could check valgrind for memory leaks with latest 3.0.x and post log from it here. |
Well i guess i need to check this myself |
For me there is no memory leak on this latest commit using phalcon_test and personnes table.
Script to reproduce: $di = new Phalcon\DI\FactoryDefault();
$di->setShared('db', function () {
$connection = new Phalcon\Db\Adapter\Pdo\Mysql([
'adapter' => 'Mysql',
'host' => 'localhost',
'port' => 3306,
'dbname' => 'phalcon_test',
'username' => 'root'
]);
return $connection;
});
Model::setup([
'notNullValidations'=>false
]);
class Personnes extends Model
{
}
$test = Personnes::find();
foreach($test as $t)
{
} Can you post your script to reproduce and database ? @tembem OR AT LEAST valgrind log |
@Jurigag Sorry, I don't know how to use valgrind, never use it before. I try to learn valgrind this weekend. Could you please help test it with Postgresql and Phalcon\Mvc\Model\Resultset\Simple? Maybe something like:
Thank you for your time |
It will always be bad. In any framework |
@sergeyklay In my real sql example there were explicit columns and some several joins, which was ran nicely with 2.1.x, not 3.0.x, unless I add memory_limit. That's the point I think. If you think there's no problem with phalcon. It's fine. I just report what I found and already close this issue by adding memory_limit and using plain pdo instead. |
@tembem Could you please provide a tables schema and models definition? |
Make sure you are doing this on this working "sample", that there will be no out of memory. Eventually try to limit your query or something @tembem :
You need to provide script to reproduce this issue, otherwise we can't deal with this. |
@sergeyklay okay, will do |
@tembem don't need to do this. --enable-debug is just php option - it will cause to php detect itself memory leaks. With valgrind you can just detect them without --enable-debug. |
Checked this on postgresql, no problem with personnes table and Personnes model from phalcon which has 2180 records. |
@Jurigag @sergeyklay Sorry, I can't run valgrind work, it's always crash :( Interesting that #12144 that happens to me as well! Maybe root of the problems is same. I create sample: <?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
$di = new Phalcon\DI\FactoryDefault();
$di->setShared('db', function () {
$connection = new Phalcon\Db\Adapter\Pdo\Postgresql([
'host' => 'localhost',
'port' => 5432,
'dbname' => 'somedb',
'username' => 'postgres',
'password' => 'passwordhere'
]);
return $connection;
});
class Roll extends Phalcon\Mvc\Model
{
public $id;
}
function bytes($size)
{
$units = [' B', ' KB', ' MB', ' GB', ' TB'];
for ($i = 0; $size >= 1024 && $i < 4; $i++)
$size /= 1024;
return round($size, 2) . $units[$i];
}
$sql = "SELECT
id,
roll_date
FROM roll
";
$item = new Roll();
$result = new Phalcon\Mvc\Model\Resultset\Simple(null, $item, $item->getReadConnection()->query($sql));
$counter = 0;
foreach ($result as $r) {
if ($counter % 1000 == 0) {
echo bytes(memory_get_usage()) . "\n";
}
if ($counter > 10000) {
die();
}
$counter++;
} PHP-7.0 + Phalcon-3.0.x 649f35c (without define all columns) 369.23 KB
5.56 MB
10.76 MB
15.97 MB
21.17 MB
26.39 MB
31.59 MB
36.78 MB
41.98 MB
47.24 MB
52.43 MB PHP-5.6 + Phalcon-2.1.x 95ef0db (without define all columns)
PHP-7.0 + Phalcon-3.0.x 649f35c (define all columns) class Roll extends Phalcon\Mvc\Model
{
public $id;
public $roll_date;
} 363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB
363.26 KB I think @Jurigag was correct, without define properties properly, script may consume memory even bigger. For bigger tables it shown Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 4096 bytes) in /var/www/test/index.php on line 40 |
I think I better close this issues, and keeping my eyes on #12144 |
Are you sure for 100% you compiled latest phalcon ? I don't have issue which you are posting and #12144 is other issue. Your issue was fixed by 7fd54ba for sure. I checked it and it's fixing it. #12144 is whole different thing and not related to your example. $di = new Phalcon\DI\FactoryDefault();
$di->setShared('db', function () {
$connection = new Phalcon\Db\Adapter\Pdo\Mysql([
'host' => 'localhost',
'port' => 3306,
'dbname' => 'phalcon_test',
'username' => 'root',
]);
return $connection;
});
Model::setup([
'notNullValidations'=>false
]);
function bytes($size)
{
$units = [' B', ' KB', ' MB', ' GB', ' TB'];
for ($i = 0; $size >= 1024 && $i < 4; $i++)
$size /= 1024;
return round($size, 2) . $units[$i];
}
class Personnes extends Model
{
public $email;
}
$sql = "SELECT email,cedula FROM personnes";
$item = new Personnes();
$test = new Phalcon\Mvc\Model\Resultset\Simple(null, $item, $item->getReadConnection()->query($sql));
$counter = 0;
foreach($test as $t)
{
if ($counter % 1000 == 0) {
echo bytes(memory_get_usage()) . "\n";
}
if ($counter > 10000) {
die();
}
$counter++;
} Is returning for me 788.24 KB 788.24 KB 788.21 KB WITHOUT FIXING #12144 |
Yes. I'm sure. Latest commit 649f35c. It's weird. Have you tried my sample code? |
But it's the same sample code, just different table, on postgresql result is the same. How you sure ? How you compiled it again exactly ? To use 3.0.x you need to use zephir i think, build folder wasn't regenerated yet so it won't work using:
Because there is just old build from 3.0 right now. Only master repository i supposed to working with default build process. To making sure you have latest version with latest changes you need to use zephir for building it. |
oh my bad I built using cd cphalcon/build
sudo ./install Thank you for mentioning this. I'll try again. |
@Jurigag you're right. Using zephir build for latest phalcon. Problem is solved Thanks a lot |
I can confirm this is working with Ubuntu 16.04 + nginx + PHP-5.6 + Phalcon-2.1.x + PostgreSQL-9.5
Yesterday, I decided to upgrade to PHP-7.0 + Phalcon-3.0.0 and found this code is not working anymore.
My result is more than 1000 items (actually ~ 4000 items), this code is working without any problem using Phalcon 2.1.x and showing in view as expected.
If the result got ~ 700 items, the code is working again.
No change in nginx.conf nor php.ini nor postgresql.conf in my installation.
Is this bug? Or I need to edit some "config" in my PHP-7.0 installation?
Ubuntu-16.04.1 LTS
PHP 7.0.8-0ubuntu0.16.04.1
Phalcon-3.0.x latest build #a48bdbb
PostgreSQL-9.5
nginx-1.10
The text was updated successfully, but these errors were encountered: