exodus4d / pathfinder

Mapping tool for EVE ONLINE
https://www.pathfinder-w.space
MIT License
386 stars 252 forks source link

When using php-redis 5.3.1, get 500 error #994

Open KagurazakaNyaa opened 4 years ago

KagurazakaNyaa commented 4 years ago

After using pecl install redis to update php-redis to version 5.3.1, a 500 error occurred when accessing the map. Also found in the error log of nginx 2020/08/24 15:29:50 [error] 7296#7296: *355458 FastCGI sent in stderr: "PHP message: Redis::set(): EXPIRE can't be < 1PHP message: [index.php:27] Base->run()" while reading response header from upstream, client: 162.158.7.131, server: map.waw-eve.com, request: "GET /api/Map/initData HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php7.3-fpm.sock:", host: "map.waw-eve.com", referrer: "https://map.waw-eve.com/map"

jediefe commented 4 years ago

Can confirm, receiving the same error.

xrem commented 4 years ago

yep. Confirm.

@exodus4d, Reproducing for next routes: /api/Map/initData /api/Map/getAccessData /api/User/getEveServerStatus

xrem commented 4 years ago

Downgraded to 5.2.1 for now.

Temporary fix: pecl install redis-5.2.1

AlfLife-eve commented 4 years ago

same error a little bump for an issue ?

TilleyTech commented 4 years ago

Im Having the same problem but installed redis via apt-get and no previous version available. Uninstalled and tried with pecl but having problems getting php to see the extension with pecl install. Any help would be mega appreciated as we are really stuck :( @exodus4d

TilleyTech commented 4 years ago

FYI anyone having this issue and struggling to downgrade using pecl it seems pecl only installs to latest version of php installed even if your using a previous. I had php 7.2 and 7.4 installed but was using 7.2 however pecl only would install to 7.4 ive switched to 7.4 and installed the previous redis and its now working

ghost commented 3 years ago

I am having the same error

tohuw commented 3 years ago

I have this issue as well. Is there no way to get it to work with my version of Redis? Downgrading to 5.2.1 is problematic for me: I have other applications on this server using Redis.

Redis server v=6.0.6 sha=00000000:0 malloc=jemalloc-5.2.1 bits=64 build=ca474e00afe358bb

Kaezon commented 3 years ago

Ran into this issue running the redis:5-alpine image

Redis server v=5.0.12 sha=00000000:0 malloc=jemalloc-5.1.0 bits=64 build=3ff07df6493cf0b8

Kaezon commented 3 years ago

As a follow-up, I tested with the 6-alpine, 5-alpine, 4-alpine, and 3-alpine tags. All gave me the same issue

Kaezon commented 3 years ago

Did a little more digging. Looking at vendor/bcosca/fatfree-core/base.php:2638 there's this line: return $this->ref->set($ndx,$data,$ttl?['ex'=>$ttl]:[]);

I went ahead and added two debug lines:

error_log('DEBUG: ttl=' . $ttl);
error_log('ex>ttl=' . print_r(['ex'=>$ttl], true));

This netted me a little more info. The set() function is called several times before the failure, with ttl values of 3, 120, and 60, but then it's called with a value of 0, which results in the error:

[11-Apr-2021 00:33:09 UTC] DEBUG: ttl= 0
[11-Apr-2021 00:33:09 UTC] ex>ttl=Array
(
    [ex] =>  0
)

[11-Apr-2021 00:33:09 UTC] Redis::set(): EXPIRE can't be &lt; 1
[11-Apr-2021 00:33:09 UTC] [vendor/bcosca/fatfree-core/base.php:2347] Base->error()
[11-Apr-2021 00:33:09 UTC] [vendor/bcosca/fatfree-core/base.php:2640] Redis->set()
[11-Apr-2021 00:33:09 UTC] [vendor/bcosca/fatfree-core/base.php:1766] Cache->set()
[11-Apr-2021 00:33:09 UTC] [index.php:27] Base->run()

Just need to figure out what function is calling it with this value and where the value is coming from now.

Kaezon commented 3 years ago

Looks like ttl is being set on vendor/bcosca/fatfree-core/base.php line 1698: list($handler,$ttl,$kbps,$alias)=$route[$this->hive['VERB']];

By dumping $route, I got several of these:

[11-Apr-2021 01:02:57 UTC] DEBUG -- ROUTE: Array
(
    [GET] => Array
        (
            [0] => Exodus4D\Pathfinder\Controller\Api\@controller->@action
            [1] =>  0
            [2] =>  512
            [3] =>
        )

    [POST] => Array
        (
            [0] => Exodus4D\Pathfinder\Controller\Api\@controller->@action
            [1] =>  0
            [2] =>  512
            [3] =>
        )

)

They appear to be routes from routes.ini, and you can see all of them have a $ttl of 0. I went ahead and tested setting all of the 0's in routes.ini to 1, and it started working.

As an example: GET|POST /api/@controller/@action [ajax] = {{ @NAMESPACE }}\Controller\Api\@controller->@action, 1, 512

beelitzs commented 3 years ago

Thanks @Kaezon , I'm using Redis 6.2.5 with PHP 7.4 and been pulling my hair out for the past 2 days until I found that workaround!