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

Uncaught error when trying to use Redis >=7.4 #2244

Closed
brutaldev opened this issue Nov 1, 2024 · 11 comments
Closed

Uncaught error when trying to use Redis >=7.4 #2244

brutaldev opened this issue Nov 1, 2024 · 11 comments
Labels
Milestone

Comments

@brutaldev
Copy link

Shlink version

4.2.4

PHP version

RoadRunner 2024.2.1

How do you serve Shlink

Docker image

Database engine

MicrosoftSQL

Database version

2022

Current behavior

Simple single instance Redis configuration does not work and throws an uncaught error on startup.

...
2024-11-01 22:39:55 Clearing entities cache... [Running "/usr/local/bin/php bin/doctrine orm:clear-cache:metadata"]   RUN  '/usr/local/bin/php' 'bin/doctrine' 'orm:clear-cache:metadata'
2024-11-01 22:39:55   ERR  
2024-11-01 22:39:55   ERR   // Clearing all Metadata cache entries                                         
2024-11-01 22:39:55   ERR  
2024-11-01 22:39:55   ERR  
2024-11-01 22:39:55   OUT  
2024-11-01 22:39:55   OUT  Fatal error: Uncaught Error: Cannot use object of type Predis\Response\Error as array in /etc/shlink/vendor/symfony/cache/Traits/RedisTrait.php:518
2024-11-01 22:39:55   OUT  Stack trace:
2024-11-01 22:39:55   OUT  #0 /etc/shlink/vendor/symfony/cache/Traits/AbstractAdapterTrait.php(133): Symfony\Component\Cache\Adapter\RedisAdapter->doClear('Shlink:')
2024-11-01 22:39:55   OUT  #1 /etc/shlink/vendor/doctrine/orm/src/Tools/Console/Command/ClearCache/MetadataCommand.php(45): Symfony\Component\Cache\Adapter\AbstractAdapter->clear()
2024-11-01 22:39:55   OUT  #2 /etc/shlink/vendor/symfony/console/Command/Command.php(279): Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
2024-11-01 22:39:55   OUT  #3 /etc/shlink/vendor/symfony/console/Application.php(1029): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
2024-11-01 22:39:55   OUT  #4 /etc/shlink/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand(Object(Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
2024-11-01 22:39:55   OUT  #5 /etc/shlink/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
2024-11-01 22:39:55   OUT  #6 /etc/shlink/vendor/doctrine/orm/src/Tools/Console/ConsoleRunner.php(30): Symfony\Component\Console\Application->run()
2024-11-01 22:39:55   OUT  #7 /etc/shlink/bin/doctrine(12): Doctrine\ORM\Tools\Console\ConsoleRunner::run(Object(Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider))
2024-11-01 22:39:55   OUT  #8 {main}
2024-11-01 22:39:55   OUT    thrown in /etc/shlink/vendor/symfony/cache/Traits/RedisTrait.php on line 518
2024-11-01 22:39:55   OUT  
2024-11-01 22:39:55   RES  255 Command did not run successfully
...
2024-11-01 22:39:55 [INFO] RoadRunner server started; version: 2024.2.1, buildtime: 2024-09-12T16:25:04+0000
2024-11-01 22:39:55 [INFO] sdnotify: not notified
2024-11-01 22:39:55 {"level":"debug","ts":1730500795373867134,"logger":"rpc","msg":"plugin was started","address":"tcp://127.0.0.1:6001","list of the plugins with RPC methods:":["jobs","lock","resetter","informer","app"]}
2024-11-01 22:39:55 2024-11-01T22:39:55+0000    DEBUG   jobs            initializing driver     {"pipeline": "shlink", "driver": "memory"}
2024-11-01 22:39:55 2024-11-01T22:39:55+0000    DEBUG   jobs            driver ready    {"pipeline": "shlink", "driver": "memory", "start": "2024-11-01T22:39:55+0000", "elapsed": 0}
2024-11-01 22:39:55 {"level":"debug","ts":1730500795374096798,"logger":"memory","msg":"pipeline was started","driver":"memory","pipeline":"shlink","start":"2024-11-01 22:39:55.37409516 +0000 UTC","elapsed":"12.301µs"}

Log on the Redis server:

SCAN  MATCH Shlink:* COUNT 1000 failed with reason: invalid cursor

Expected behavior

Basic Redis configuration should just work.

Minimum steps to reproduce

Run the following Docker Compose:

networks:
  shared:
    name: shared-network
    
services:
  redis:
    container_name: redis
    image: redis:latest
    restart: unless-stopped
    ports:
      - 6379:6379
    networks:
      - shared

  shlink:
    container_name: shlink
    image: shlinkio/shlink:stable-roadrunner
    restart: unless-stopped
    ports:
      - 8080:8080
    environment:
      - "DEFAULT_DOMAIN=s.test"
      - "IS_HTTPS_ENABLED=false"
      - "SKIP_INITIAL_GEOLITE_DOWNLOAD=true"
      - "SHORT_URL_TRAILING_SLASH=true"
      - "SHELL_VERBOSITY=3"
      - "REDIS_SERVERS=tcp://redis:6379/0"
      - "REDIS_PUB_SUB_ENABLED=true"
    networks:
      - shared
    depends_on:
      - redis

Shlink starts up but fails when trying to use Redis.

@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

I think the Cannot use object of type Predis\Response\Error as array error is just a side effect of symphony/cache not fully supporting Predis 2.

The actual error is likely something else. For example, the first problem I see in your docker compose config is that you are missing the link between the shlink and redis services.

networks:
  shared:
    name: shared-network
    
services:
  redis:
    container_name: redis
    image: redis:latest
    restart: unless-stopped
    ports:
      - 6379:6379
    networks:
      - shared

  shlink:
    container_name: shlink
    image: shlinkio/shlink:stable-roadrunner
    restart: unless-stopped
    ports:
      - 8080:8080
    environment:
      - "DEFAULT_DOMAIN=s.test"
      - "IS_HTTPS_ENABLED=false"
      - "SKIP_INITIAL_GEOLITE_DOWNLOAD=true"
      - "SHORT_URL_TRAILING_SLASH=true"
      - "SHELL_VERBOSITY=3"
      - "REDIS_SERVERS=tcp://redis:6379/0"
      - "REDIS_PUB_SUB_ENABLED=true"
    networks:
      - shared
    depends_on:
      - redis
+   links:
+     - redis

Can you try if it works with that?

@brutaldev
Copy link
Author

@acelaya Thanks, but adding the links property unfortunately has no effect and the error message remains.
I use a much more complex compose file where other services are also dependant on Redis and they connect successfully, it's only Shlink that is failing in this case.

We've also tried this in the cloud where we first noticed the error, so I went ahead and reproduced this locally to report it. I've also tried using other Redis drop-ins like Dragonfly and Garnet with the same results so I'm completely stumped as to why this happens.

@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

Thanks for the confirmation.

I will try to find out what is the root error being thrown, as you provided very useful and concrete reproducible steps (much appreciated).

@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

Ok, I think I found something. It seems to be related with redis version. I suppose the abstraction libraries used by Shlink do not yet support everything.

These versions worked for me:

  • redis:6.2-alpine
  • redis:7.0-alpine
  • redis:7.2-alpine

And these didn't:

I'm not sure what's the difference between 7 and 7.0 though EDIT: Actually, just noticed latest 7.x is 7.4, so that's the difference. I have updated the lists above.

Could you try one of the above?

@acelaya acelaya changed the title Uncaught error when trying to use single instance Redis configuration Uncaught error when trying to use Redis >=7.4 Nov 2, 2024
@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

I've been able to reproduce the issue in a development environment. I'm going to try to dig what's the actual difference between redis 7.4 and older versions, and report it to the appropriate project, or fix it here if possible.

@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

This is the root cause symfony/symfony#58660

@acelaya acelaya added this to the 4.2.5 milestone Nov 2, 2024
@acelaya acelaya added the blocked Issues with some external dependency preventing to work on them label Nov 2, 2024
@acelaya
Copy link
Member

acelaya commented Nov 2, 2024

Marking as blocked until the issue is fixed upstream. I'll release a patch version once it has been fixed.

In the meantime, using redis 7.2 should work.

@acelaya acelaya pinned this issue Nov 2, 2024
@brutaldev
Copy link
Author

@acelaya Thanks for looking into this, I'll monitor progress and wait for an update release.

@acelaya acelaya removed the blocked Issues with some external dependency preventing to work on them label Nov 3, 2024
@acelaya
Copy link
Member

acelaya commented Nov 3, 2024

I'm unblocking this, as there's a simple workaround that can be put in place until this has been fixed upstream.

@acelaya
Copy link
Member

acelaya commented Nov 3, 2024

I have just released v4.2.5. Docker images are being built at the moment, and will be available once https://github.com/shlinkio/shlink/actions/runs/11650632374 has finished.

Could you test it afterwards?

@acelaya acelaya closed this as completed Nov 3, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Shlink Nov 3, 2024
@acelaya acelaya unpinned this issue Nov 4, 2024
@brutaldev
Copy link
Author

@acelaya Tested and working. Thanks for the quick fix!

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

No branches or pull requests

2 participants