Cloud Run not catching signal: 11 after upgrading Laravel 9
P粉739886290
2023-08-31 09:23:32
<p>I upgraded my project to Laravel 9 using PHP8. But since I'm deploying on Cloud Run, I randomly get the following error in the Cloud Run log: </p>
<p><code> Uncaught signal: 11, pid=17, tid=17, fault_addr=4294967296017.</code></p>
<p>因此查询因 503 错误而中止:<code>GET 503 898 octets 682 msChrome 109 https://...</code></p>
<p>这是我的 php-custom.ini :</p>
<pre class="brush:php;toolbar:false;">max_execution_time = 500
upload_max_filesize = 40M
post_max_size = 40M
memory_limit = 800M
max_file_uploads = 100</pre>
<p>还有我的 opcache.ini :</p>
<pre class="brush:php;toolbar:false;">[opcache]
opcache.enable=1
opcache.enable_cli=1
opcache.revalidate_freq=0
opcache.validate_timestamps=0
opcache.max_accelerated_files=32531
opcache.memory_consumption=256
opcache.max_wasted_percentage=10
opcache.interned_strings_buffer=64
opcache.fast_shutdown=1
opcache.jit_buffer_size=100M
opcache.jit=1235</pre>
<p>还有我的 dockerfile:</p>
<pre class="brush:php;toolbar:false;">FROM php:8.2.3-apache as base
# Arguments defined in docker-compose.yml
ARG user
ARG uid
WORKDIR /app
# Install PHP dependencies
RUN apt-get update && apt-get install -y \
libpng-dev \
zlib1g-dev \
libxml2-dev \
libzip-dev \
libonig-dev \
zip \
unzip \
locales \
pdftk \
&& sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen \
&& locale-gen \
&& docker-php-ext-configure gd \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install pdo_mysql \
&& docker-php-ext-install mysqli \
&& docker-php-ext-install zip \
&& docker-php-source delete \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-install opcache \
&& docker-php-ext-install bcmath
# Env
ENV LC_ALL fr_FR.UTF-8
ENV LANG fr_FR.UTF-8
ENV LANGUAGE fr_FR:en
# Copy project, vhost.conf, config php and install composer
COPY . .
COPY docker/vhost.conf /etc/apache2/sites-available/000-default.conf
COPY docker/custom.ini $PHP_INI_DIR/conf.d/custom.ini
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
RUN sed -i 's/80/${PORT}/g' /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf
# Add permissions
RUN mkdir -p /app/vendor \
mkdir -p /app/storage/logs \
&& useradd -G www-data,root -u $uid -d /home/$user $user \
&& mkdir -p /home/$user/.composer \
&& chown -R $user:$user /home/$user \
&& chown -R $user:$user /app \
&& a2enmod rewrite \
&& chmod x docker/startup-dev.sh \
&& chmod x docker/startup-prod.sh
EXPOSE 8080
FROM base as development
RUN apt-get update && apt-get install -y nano
ENTRYPOINT ["docker/startup-dev.sh"]
CMD ["apache2-foreground"]
USER $user
FROM base as production
COPY docker/opcache.ini $PHP_INI_DIR/conf.d/opcache.ini
RUN composer clearcache && composer install --optimize-autoloader --no-dev
ENTRYPOINT ["docker/startup-prod.sh"]
CMD ["apache2-foreground"]
USER $user</pre>
<p>我不知道如何重现该错误,因为它非常随机,但我注意到该错误是在 Cloud Run 冷启动后出现的。我不知道问题是否是由我的 opcache 配置引起的。我的云运行服务有 1 个 CPU 和 2 个 GO 内存。</p>
<p>我不知道如何解决这个问题。</p>
<p><strong>编辑</strong></p>
<p>当我收到错误时,我添加了 2 个图表:</p>
I solved my problem. This has nothing to do with Cloud Run. The problem is the JIT configuration. I changed this:
to
According to this: https://php.watch/versions /8.0/JIT#jit-opcache-jit-values I also tried:
If you don't want to use 1255, it will work too. But I used
1255
because in this pull request I saw a lot of unit tests for 1255 configurations.