cphalcon icon indicating copy to clipboard operation
cphalcon copied to clipboard

PHP7-Fpm+Nginx /mvc/model/query.zep

Open renatogabrielbr opened this issue 10 years ago • 12 comments

Zephir And Phalcon build yesterday - Last version.

Looks like something going wrong with parse function i gotta memory leak

( ! ) Fatal error: Allowed memory size of 1585446912 bytes exhausted (tried to allocate 2401512287 bytes) in /var/www/html/teste2/apps/frontend/controllers/IndexController.php on line 12

NotWorking

$model = new Tst();
var_dump($model->find());exit;
var_dump($model->count());exit;

Working

$as = $this->db->query('SELECT * FROM tst');
$result = $as->execute();
var_dump($as->fetchAll());exit;

Log find $model = new Tst(); var_dump($model->find());exit;

#   Time    Memory  Function    Location
1   0.0018  359608  {main}( )   .../index.php:0
2   0.0143  391104  handle ( )  .../index.php:36
3   0.0242  417984  dispatch ( )    .../index.php:36
4   0.0242  418016  _dispatch ( )   .../index.php:36
5   0.0387  425448  callActionMethod ( object(Teste\Frontend\Controllers\IndexController)[31], string(11), array(0) )   .../index.php:36
6   0.0387  425832  Teste\Frontend\Controllers\IndexController->indexAction( )  .../index.php:36
7   0.0403  438856  Teste\Frontend\Models\Tst::find( ??? )  .../IndexController.php:12
8   0.0403  438856  find ( null )   .../Tst.php:38
9   0.0408  442920  execute ( ) .../Tst.php:38
10  0.0408  442944  parse ( )

Log Count $model = new Tst(); var_dump($model->count());exit;

#   Time    Memory  Function    Location
1   0.0002  359608  {main}( )   .../index.php:0
2   0.0014  391104  handle ( )  .../index.php:36
3   0.0032  417984  dispatch ( )    .../index.php:36
4   0.0032  418016  _dispatch ( )   .../index.php:36
5   0.0067  420920  callActionMethod ( object(Teste\Frontend\Controllers\IndexController)[31], string(11), array(0) )   .../index.php:36
6   0.0067  421304  Teste\Frontend\Controllers\IndexController->indexAction( )  .../index.php:36
7   0.0073  434328  count ( )   .../IndexController.php:12
8   0.0073  434432  _groupResult ( string(5), string(8), null ) .../IndexController.php:12
9   0.0077  438576  execute ( null, null )  .../IndexController.php:12
10  0.0077  438600  parse ( )   .../IndexController.php:12

renatogabrielbr avatar Mar 25 '16 19:03 renatogabrielbr

As i remember:

var_dump($model->find());

Will cause this almost always out of memory/allowed size beacause there are recursive calls to di, this will cause to var_dump all models with di, if you have some service registered in it, which have di - it will be dumped again etc etc. It will really cost many memory, just huge amount of it and it's possible that it's have problem with dumping it.

For dumping resultset use:

var_dump($model->find()->toArray());

$model->count() is not working too ?

Jurigag avatar Mar 25 '16 20:03 Jurigag

Already tried, withou var_dump setting as a variable. $as = $model->find(); $as = Tst::find();

No operation throught Model is working save(), delete().

save and delete is even worst nginx redirect me to 404.

renatogabrielbr avatar Mar 25 '16 20:03 renatogabrielbr

So what database you are using ? Is the same occuring on php 5.6 ?

Jurigag avatar Mar 25 '16 20:03 Jurigag

I`m trying php 7 + phalcon 2.1 + mariadb 10.0 PDO_MYSQL + Ubuntu 15.10 Server x64 php 5.6 + phalcon 2.0.10 is working fine

and just to be clear the problem is with the Model, View, Controller, Router.... is working fine.

Database is simple just for test 1 table tst fields id and title. and works if i use

$as = $this->db->query('SELECT * FROM tst'); $result = $as->execute(); var_dump($as->fetchAll());exit;

renatogabrielbr avatar Mar 25 '16 20:03 renatogabrielbr

Phalcon 2.1 is currently not stable with php 7, just dont use it on php 7, that's all.

Jurigag avatar Mar 25 '16 20:03 Jurigag

OK, i know it, but i m reporting a issue, Have you been used php7 + phalcon2.1? tried model?

renatogabrielbr avatar Mar 25 '16 20:03 renatogabrielbr

But phalcon is officially not released for php 7. There are many bugs and other things that you need to know about php 7. There are zephir issues, i added some with php 7:

https://github.com/phalcon/zephir/issues

Those problems can occur in many places beacause phalcon is using similar code many times. We have to fix most of problems in zephir, then we can test phalcon again.

Right now there is no sense of reporting any phalcon problems with php7 beacause we simply don't know if it's phalcon related or zephir related. At least not with information you provided.

Jurigag avatar Mar 25 '16 21:03 Jurigag

ok i tried to report, looks like somenthing in parse, because if dont need to use function parse, works. but ok good luck

renatogabrielbr avatar Mar 25 '16 21:03 renatogabrielbr

There are seg faults in tests running on php7. There can be like 100 other problems and you don't know about it. We need to fix current found problems in zephir, make tests working without seg faults:

https://github.com/phalcon/cphalcon/issues/11550

We have to make them passing and then we could possible focus on other php 7 related issues which will be not found in tests.

Right know i think there is no sense of reporting other issues.

At least i think so, but don't know, maybe @sergeyklay or @andresgutierrez have other opinion and they need all feedback from phalcon with php7 they can but my guess this problem if test will be going without segfault will occur too.

Jurigag avatar Mar 25 '16 21:03 Jurigag

Ok, no problem, just warning because i thought weird, all work less MODEL, even so pdo is working inside phalcon. but good luck with zephir anyway.

renatogabrielbr avatar Mar 25 '16 22:03 renatogabrielbr

As you can see in issue more things not working for example logger or config.

Jurigag avatar Mar 25 '16 23:03 Jurigag

Yes, I did know already, i did read, i follow, and always use phalcon, when i can i help also, wish i could do more.

First i had opened on forum and i just brought to here, because i really forgot about zephir is not 100% ready yet on zend engine 3.

I saw the RC1, and did not look into zephir.

But Anyway already bring, maybe one day help, maybe get fixed when zephir get done ( i hope so ) and by the phalcon extension code looks like parse always is return when is a phql

Anyway still the best framework, faster than php 7 !! haha

I had to stop my hunting here because i do not understand so much ZendEngine

int phql_parse_phql(zval *result, zval *phql TSRMLS_DC) {

    zval *error_msg = NULL;

    ZVAL_NULL(result);

    if (phql_internal_parse_phql(&result, Z_STRVAL_P(phql), Z_STRLEN_P(phql), &error_msg TSRMLS_CC) == FAILURE) {
        ZEPHIR_THROW_EXCEPTION_STRW(phalcon_mvc_model_exception_ce, Z_STRVAL_P(error_msg));
        return FAILURE;
    }

    return SUCCESS;
}

Going to** \phalcon\mvc\model\query\parser.c** ( where looks like by the comments that are ready to php7 not sure). phql_internal_parse_phql

renatogabrielbr avatar Mar 26 '16 00:03 renatogabrielbr