You are not logged in.

Announcement

 Téléchargez la dernière version stable de GLPI      -     Et vous, que pouvez vous faire pour le projet GLPI ? :  Contribuer
 Download last stable version of GLPI                      -     What can you do for GLPI ? :  Contribute

#1 2025-03-14 15:10:54

RogerioMax
Member
Registered: 2023-11-28
Posts: 7

"PHP Error (1): Allowed memory size of"

Bom dia!

Estou tendo este erro ao tentar efetuar filtros dentro do GLPI que sejam de longos períodos ou desde seu início. Mesmo alterando o Cache PHP para 512M, o problema não foi solucionado. Sempre acusa estar em "in /usr/share/glpi/inc/dbmysql.class.php at line 299". A linha 299 é a "$res = $this->dbh->query($query);"

A função é esta abaixo

/**
    * Execute a MySQL query
    *
    * @param string $query Query to execute
    *
    * @var array   $CFG_GLPI
    * @var array   $DEBUG_SQL
    * @var integer $SQL_TOTAL_REQUEST
    *
    * @return mysqli_result|boolean Query result handler
    *
    * @throws GlpitestSQLError
    */
   function query($query) {
      global $CFG_GLPI, $DEBUG_SQL, $GLPI, $SQL_TOTAL_REQUEST;

      $is_debug = isset($_SESSION['glpi_use_mode']) && ($_SESSION['glpi_use_mode'] == Session::DEBUG_MODE);
      if ($is_debug && $CFG_GLPI["debug_sql"]) {
         $SQL_TOTAL_REQUEST++;
         $DEBUG_SQL["queries"][$SQL_TOTAL_REQUEST] = $query;
      }
      if ($is_debug && $CFG_GLPI["debug_sql"] || $this->execution_time === true) {
         $TIMER                                    = new Timer();
         $TIMER->start();
      }

    $res = $this->dbh->query($query);   
      if (!$res) {
         // no translation for error logs
         $error = "  *** MySQL query error:\n  SQL: ".$query."\n  Error: ".
                   $this->dbh->error."\n";
         $error .= Toolbox::backtrace(false, 'DBmysql->query()', ['Toolbox::backtrace()']);

         Toolbox::logSqlError($error);

         $error_handler = $GLPI->getErrorHandler();
         if ($error_handler instanceof ErrorHandler) {
            $error_handler->handleSqlError($this->dbh->errno, $this->dbh->error, $query);
         }

         if (($is_debug || isAPI()) && $CFG_GLPI["debug_sql"]) {
            $DEBUG_SQL["errors"][$SQL_TOTAL_REQUEST] = $this->error();
         }
      }

      if ($is_debug && $CFG_GLPI["debug_sql"]) {
         $TIME                                   = $TIMER->getTime();
         $DEBUG_SQL["times"][$SQL_TOTAL_REQUEST] = $TIME;
         $DEBUG_SQL['rows'][$SQL_TOTAL_REQUEST] = $this->affectedRows();
      }
      if ($this->execution_time === true) {
         $this->execution_time = $TIMER->getTime(0, true);
      }
      return $res;
   }

Alteramos também no Arquivo /etc/mysql/mariadb.conf.d/50-server.cnf e abaixo, porém continua com o erro. Alguém já viu esse problema?

# Enable the slow query log to see queries with especially long duration
#slow_query_log_file    = /var/log/mysql/mariadb-slow.log
#long_query_time        = 10
#log_slow_rate_limit    = 1000
#log_slow_verbosity     = query_plan
#log-queries-not-using-indexes
#
# The following can be used as easy to replay backup logs or for replication.
# note: if you are setting up a replication slave, see README.Debian about
#       other settings you may need to change.
server-id              = 1
log_bin                = /var/lib/mysql/mysql-bin
expire_logs_days       = 2
max_binlog_size        = 2G
max_binlog_cache_size  = 2G
#binlog_do_db           = include_database_name
#binlog_ignore_db       = exclude_database_name

Offline

#2 2025-03-26 18:34:07

richard.infoo
Member
From: Brasil
Registered: 2022-08-10
Posts: 79
Website

Re: "PHP Error (1): Allowed memory size of"

@RogerioMax, boa tarde!
Talvez isso possa ajudar, mas para consultas muito longas e complexas, aconselho utilizar alguma ferramenta de BI ou consultar diretamente pelo banco de dados.

Ajuste do max_execution_time no PHP no arquivo php.ini, altere o valor para algo maior, por exemplo:
max_execution_time = 300  ; 300 segundos = 5 minutos

Reinicie o servidor web após essa alteração para garantir que as novas configurações sejam aplicadas.


Consultoria em GLPI, ITIL4, ITSM, HDI, LGPD e DPO. 
Contato: (32) 98469-2962 | richard.infoo@gmail.com 

Att, Richard Loureiro, Consultor Especialista Certificado ITIL4 PeopleCert.

Offline

Board footer

Powered by FluxBB