Scalingo / php-buildpack

Official Scalingo buildpack - Based on CHH php buildpack, Nginx/PHP-fpm stack
MIT License
16 stars 36 forks source link

How to install a specific version of phpredis? #395

Open potsky opened 9 months ago

potsky commented 9 months ago

Hi !

Since the upgrade from 5.3.7 to 6.0.2 of phpredis on December the 20th, we have a lot of problems of this kind : Redis::exec(): Send of 463 bytes failed with errno=32 Broken pipe or Redis server tcp://xxx.redis.dbs.scalingo.com:xx went away.

We have checked with the Scalingo support team the Redis and app logs, we have check our code, the dependencies upgrades... With 5.x everything were working find for years. So we would like to test a previous version of the extension.

So we have forked the PHP buildpack and have replaced the GitHub repository in our app in the .buildpacks file. Given than the commit where phpredis has been upgraded from 5.3.7 to 6.0.2 is a little bit more complicated (the variable phpredis_version did not exist before), we have tested to load the version 6.0.1 in our fork :

1 fork a

We have added debug information to check our fork is taken into account. It is correctly loaded when deploying :

1 fork b

Before deploying, we have clear the deploy cache on the dashboard. During deployment, everything is ok, version 6.0.1 is downloaded and used:

2 deploy

But when the deployment is done, phpinfo always tells us that PHP is using version 6.0.2 :-(

3 phpinfo

  1. Is our buildpack really used?
  2. Have we missed something?
  3. Do we must keep the Scalingo buildpack ? If so, we can send a PR to let user configure the wanted version from an ENV variable for example. What do you think about this?

Thank you for your answer!

potsky commented 9 months ago

Hello @Frzk,

I'm sorry to put the pressure on you, but our Scalingo app is a disaster. We're losing a lot of jobs, contract signatures aren't synchronized with YouSign, meter synchronization with Enedis and GRDF isn't working, and things are getting very, very tense on our side.

How can I rollback phpredis very quickly? Do you have any ideas? How can we help?

Frzk commented 9 months ago

Hello @potsky, I'm very sorry to read that :-( Until we can come up with a cleaner solution, I suggest you to try the following (not tested yet):

I'm currently testing this solution. Also please don't hesitate to ask our support operators to talk to me if need be.

Frzk commented 9 months ago

After testing, it seems it's a bit more complicated. Here is the full procedure:

potsky commented 9 months ago

Thank you @Frzk ❤️

We have followed your guide (just replaced our buildpack in our .buildpack file, we have APT and NodeJS too).

The correct version seems to be installed in the deploy: Installing PECL extension redis version 5.3.7

But an error occurs several lines below when downloading sodium extension:

       Installing PECL extension redis version 5.3.7
       PHP extension simplexml is embedded in runtime
       Installing PECL extension sodium version <!DOCTYPE html>
       <html lang="en">
       <head>
           <title>PECL :: Error 404 not found</title>
           <link rel="shortcut icon" href="/favicon.ico">
           <link rel="alternate" type="application/rss+xml" title="RSS feed" href="https://pecl.php.net/feeds/latest.rss">
           <link rel="stylesheet" href="/css/style.css">
           </head>

       <body >
 ...
Frzk commented 9 months ago

Mmh that's probably linked to the package_found=false modification in lib/composer.

I suggest to edit this file (lib/composer) again, like so:

  1. Uncomment the line starting with package_found="$(has_package ...
  2. Remove the package_found="false" line
  3. Replace the conditional statement that follows with this one:
    if [[ "${package_found}" = "true" && ! "${ext}" =~ "redis" ]] ; then

Which would give:

[...]
local extension_package_path="ext/$(php_api_version)/php-${ext}"
package_found="$(has_package "${PHP_BASE_URL}" "${extension_package_path}")"

if [[ "${package_found}" = "true" && ! "${ext}" =~ "redis" ]] ; then
    echo "Installing PHP extension: ${ext}" | indent
    fetch_package "${PHP_BASE_URL}" "${extension_package_path}" "/app/vendor/php"
else
    install_pecl_extension "${ext}" "${ext_version}" "${CACHE_DIR}"
fi
[...]
potsky commented 9 months ago

Thank you @Frzk you rock!

Screenshot 2024-01-17 - 16-43-08@2x

It works as expected, we will push this on production now and check if problem is resolved. I will keep you informed about this version of phpredis in several days.

Thanx!

Frzk commented 9 months ago

Great to read that :)

Please note that this is only a workaround. We'll probably update the buildpack in a way that allows users to pin a specific version of the default extensions.

When/If this update becomes available, you'll be able to switch back to the default buildpack.

I'm reopening this issue until we've decided what to do exactly.

potsky commented 9 months ago

I have set a reminder to tell you in a few days if the error has disappeared with 5.3.7 on production.... Keep in touch !

potsky commented 9 months ago

Hi @Frzk !

as promised, I'm back with great news for us: we haven't had a single error with phpredis 5.3.7, whereas we had hundreds of thousands with 6.0.2 in just a few days.

So we're going to stay with 5.3.7 for the time being, and if it's possible to go back to Scalingo buildpack and stop using our fork by being able to specify the extension version in the environment variables, for example, that would be just ideal.

I've opened an issue on https://github.com/phpredis/phpredis/issues/2437 to see if someone has an idea...