Skip to content
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

How to install a specific version of phpredis? #395

Open
potsky opened this issue Jan 14, 2024 · 9 comments
Open

How to install a specific version of phpredis? #395

potsky opened this issue Jan 14, 2024 · 9 comments
Assignees

Comments

@potsky
Copy link

potsky commented Jan 14, 2024

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!

@Frzk Frzk self-assigned this Jan 15, 2024
@potsky
Copy link
Author

potsky commented Jan 17, 2024

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
Copy link
Contributor

Frzk commented Jan 17, 2024

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):

  • Fork our buildpack
  • In your fork, edit the bin/compile file and comment lines 296 and 297 (which install our phpredis default version)
  • In your application, edit your composer.json file and add the following line in your require section:
    "ext-redis": "5.3.7",
  • Re-generate your composer.lock file
  • Tell the platform to use your fork, instead of our buildpack:
    scalingo --app <my-app> env-set BUILDPACK_URL="<buildpack_url>"
    (please replace <my-app> with the actual name of your app and <buildpack_url> with the URL to your forked and edited buildpack).

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

@Frzk
Copy link
Contributor

Frzk commented Jan 17, 2024

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

  • Fork our buildpack
  • In your fork, edit the bin/compile file and comment lines 296 and 297 (which install our phpredis default version)
  • In your fork, edit the lib/composer file and comment line 125. Just below add the following line:
    package_found="false"
    
  • In your fork, edit the conf/buildpack.conf file and set the phpredis_version variable to 5.3.7.
  • In your application, edit your composer.json file and add the following line in your require section:
    "ext-redis": "5.3.7",
  • Re-generate your composer.lock file
  • Tell the platform to use your fork, instead of our buildpack:
    scalingo --app <my-app> env-set BUILDPACK_URL="<buildpack_url>"
    (please replace <my-app> with the actual name of your app and <buildpack_url> with the URL to your forked and edited buildpack).
  • Empty your deployment cache:
    scalingo --app <my-app> deployment-delete-cache
  • Trigger a new deployment

@potsky
Copy link
Author

potsky commented Jan 17, 2024

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
Copy link
Contributor

Frzk commented Jan 17, 2024

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
Copy link
Author

potsky commented Jan 17, 2024

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!

@potsky potsky closed this as completed Jan 17, 2024
@Frzk
Copy link
Contributor

Frzk commented Jan 17, 2024

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.

@Frzk Frzk reopened this Jan 17, 2024
@potsky
Copy link
Author

potsky commented Jan 17, 2024

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
Copy link
Author

potsky commented Jan 21, 2024

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 phpredis/phpredis#2437 to see if someone has an idea...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants