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

FileCache: Fix parsing issue on already removed or empty file #87

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Rakdos8
Copy link
Contributor

@Rakdos8 Rakdos8 commented May 12, 2023

$ cat 2023-05-12-php_errors.log | grep "Call to a member function expired() on bool" | wc -l
18
$ cat 2023-05-12-php_errors.log | grep "Call to a member function expired() on bool" -A 1
[12/05/2023 14:54:17] Message: Call to a member function expired() on bool
[12/05/2023 14:55:18] Stack trace: #0 /data/www/evemyadmin/web/vendor/eveseat/eseye/src/Cache/FileCache.php(181): Seat\Eseye\Cache\FileCache->get()
--
[12/05/2023 14:55:18] Message: Call to a member function expired() on bool
[12/05/2023 14:55:18] Stack trace: #0 /data/www/evemyadmin/web/vendor/eveseat/eseye/src/Cache/FileCache.php(181): Seat\Eseye\Cache\FileCache->get()

I'm having this kind of error several times per day (18 times today) due to possible multiple call to the endpoint (multi threading).
Waiting for 24 hours before sending this PR for review (trying this on my instance first)

@Rakdos8 Rakdos8 marked this pull request as draft May 12, 2023 19:14
@warlof
Copy link
Member

warlof commented May 13, 2023

Already ha seen such issue - I think it was a serialize issue.
What could make the file readable but prevent thread to consume its content ?

@Rakdos8
Copy link
Contributor Author

Rakdos8 commented May 13, 2023

I firstly thought it was an issue in the file itself : content is empty or file deleted. Yet, even with my patch I had the same error today somehow so it should be an issue in the unserialize method as you think.
The content (in the file) should be corrupted or something. and leads to a unserialize failure.

I'm trying to catch the error and check the read content to so what's going on. For now, I'm waiting that the issue occur again. I will update this issue when ready.

@Rakdos8
Copy link
Contributor Author

Rakdos8 commented May 14, 2023

I finally had the error back today (had to wait) and I suspect somehow an issue with CCP : when the market endpoint was restored (a few days ago) I had several issues of this kind (the main reason I opened this PR).
Now, I face this issue 1 per day max still on the same route (the market history).

Here is the content of the file when parsed following this PHP code :

// Get the data from the file and unserialize it
$data = @unserialize($content);
if (is_bool($data)) {
	throw new \ErrorException('unserialize is a bool : ' . ($data ? 'true': 'false') . '. File content = "' . print_r($content, true) . '"');
}

The exception, when wrote down on my custom logger says :

[14/05/2023 19:49:46] Exception: ErrorException
[14/05/2023 19:49:46] Message: unserialize is a bool : false. File content = "O:33:"Seat\Eseye\Containers\EsiResponse":4:{i:0;i:2;i:1;a:65:{i:0;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-04-04";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:2;s:6:"volume";i:4;}i:1;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2022-04-10";s:7:"highest";d:16000000;s:6:"lowest";d:10000000;s:11:"order_count";i:2;s:6:"volume";i:5;}i:2;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-04-11";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:3;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-04-12";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:1;s:6:"volume";i:5;}i:4;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-04-13";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:5;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-04-15";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:6;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-04-18";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:2;s:6:"volume";i:2;}i:7;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-04-20";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:8;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-04-21";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:2;s:6:"volume";i:3;}i:9;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-04-22";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:1;s:6:"volume";i:3;}i:10;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-04-28";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:11;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-04-29";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:2;s:6:"volume";i:3;}i:12;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-05-03";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:13;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-05-08";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:14;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-05-11";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:15;O:8:"stdClass":6:{s:7:"average";d:11500000;s:4:"date";s:10:"2022-05-27";s:7:"highest";d:11500000;s:6:"lowest";d:11500000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:16;O:8:"stdClass":6:{s:7:"average";d:10000000;s:4:"date";s:10:"2022-05-31";s:7:"highest";d:10000000;s:6:"lowest";d:10000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:17;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-06-20";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:2;s:6:"volume";i:2;}i:18;O:8:"stdClass":6:{s:7:"average";d:9999000;s:4:"date";s:10:"2022-06-26";s:7:"highest";d:9999000;s:6:"lowest";d:9999000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:19;O:8:"stdClass":6:{s:7:"average";d:9994500;s:4:"date";s:10:"2022-07-17";s:7:"highest";d:10000000;s:6:"lowest";d:9989000;s:11:"order_count";i:2;s:6:"volume";i:2;}i:20;O:8:"stdClass":6:{s:7:"average";d:9990000;s:4:"date";s:10:"2022-07-23";s:7:"highest";d:9990000;s:6:"lowest";d:9990000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:21;O:8:"stdClass":6:{s:7:"average";d:11300000;s:4:"date";s:10:"2022-07-27";s:7:"highest";d:11300000;s:6:"lowest";d:11300000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:22;O:8:"stdClass":6:{s:7:"average";d:11490000;s:4:"date";s:10:"2022-08-01";s:7:"highest";d:11490000;s:6:"lowest";d:11490000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:23;O:8:"stdClass":6:{s:7:"average";d:11490000;s:4:"date";s:10:"2022-08-14";s:7:"highest";d:11490000;s:6:"lowest";d:11490000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:24;O:8:"stdClass":6:{s:7:"average";d:1200000;s:4:"date";s:10:"2022-09-26";s:7:"highest";d:1200000;s:6:"lowest";d:1200000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:25;O:8:"stdClass":6:{s:7:"average";d:1200000;s:4:"date";s:10:"2022-09-30";s:7:"highest";d:1200000;s:6:"lowest";d:1200000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:26;O:8:"stdClass":6:{s:7:"average";d:1200000;s:4:"date";s:10:"2022-10-01";s:7:"highest";d:1200000;s:6:"lowest";d:1200000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:27;O:8:"stdClass":6:{s:7:"average";d:5701000;s:4:"date";s:10:"2022-10-25";s:7:"highest";d:5701000;s:6:"lowest";d:5701000;s:11:"order_count";i:3;s:6:"volume";i:3;}i:28;O:8:"stdClass":6:{s:7:"average";d:5701000;s:4:"date";s:10:"2022-11-07";s:7:"highest";d:5701000;s:6:"lowest";d:5701000;s:11:"order_count";i:1;s:6:"volume";i:4;}i:29;O:8:"stdClass":6:{s:7:"average";d:5701000;s:4:"date";s:10:"2022-11-08";s:7:"highest";d:5701000;s:6:"lowest";d:5701000;s:11:"order_count";i:1;s:6:"volume";i:32;}i:30;O:8:"stdClass":6:{s:7:"average";d:11666666.67;s:4:"date";s:10:"2022-11-25";s:7:"highest";d:12500000;s:6:"lowest";d:10000000;s:11:"order_count";i:3;s:6:"volume";i:3;}i:31;O:8:"stdClass":6:{s:7:"average";d:14000000;s:4:"date";s:10:"2022-11-26";s:7:"highest";d:14000000;s:6:"lowest";d:14000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:32;O:8:"stdClass":6:{s:7:"average";d:14000000;s:4:"date";s:10:"2022-11-27";s:7:"highest";d:14000000;s:6:"lowest";d:14000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:33;O:8:"stdClass":6:{s:7:"average";d:11500000;s:4:"date";s:10:"2022-11-29";s:7:"highest";d:14000000;s:6:"lowest";d:10000000;s:11:"order_count";i:3;s:6:"volume";i:14;}i:34;O:8:"stdClass":6:{s:7:"average";d:16000000;s:4:"date";s:10:"2022-12-01";s:7:"highest";d:16000000;s:6:"lowest";d:16000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:35;O:8:"stdClass":6:{s:7:"average";d:15000000;s:4:"date";s:10:"2022-12-04";s:7:"highest";d:15000000;s:6:"lowest";d:15000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:36;O:8:"stdClass":6:{s:7:"average";d:15000000;s:4:"date";s:10:"2022-12-17";s:7:"highest";d:15000000;s:6:"lowest";d:15000000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:37;O:8:"stdClass":6:{s:7:"average";d:15000000;s:4:"date";s:10:"2022-12-20";s:7:"highest";d:15000000;s:6:"lowest";d:15000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:38;O:8:"stdClass":6:{s:7:"average";d:15000000;s:4:"date";s:10:"2022-12-23";s:7:"highest";d:15000000;s:6:"lowest";d:15000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:39;O:8:"stdClass":6:{s:7:"average";d:15000000;s:4:"date";s:10:"2022-12-24";s:7:"highest";d:15000000;s:6:"lowest";d:15000000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:40;O:8:"stdClass":6:{s:7:"average";d:13500000;s:4:"date";s:10:"2022-12-29";s:7:"highest";d:13500000;s:6:"lowest";d:13500000;s:11:"order_count";i:1;s:6:"volume";i:3;}i:41;O:8:"stdClass":6:{s:7:"average";d:13500000;s:4:"date";s:10:"2023-01-02";s:7:"highest";d:13500000;s:6:"lowest";d:13500000;s:11:"order_count";i:1;s:6:"volume";i:14;}i:42;O:8:"stdClass":6:{s:7:"average";d:14000000;s:4:"date";s:10:"2023-01-03";s:7:"highest";d:14000000;s:6:"lowest";d:14000000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:43;O:8:"stdClass":6:{s:7:"average";d:14000000;s:4:"date";s:10:"2023-01-04";s:7:"highest";d:14000000;s:6:"lowest";d:14000000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:44;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2023-01-09";s:7:"highest";d:11200000;s:6:"lowest";d:11200000;s:11:"order_count";i:1;s:6:"volume";i:20;}i:45;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2023-01-10";s:7:"highest";d:11200000;s:6:"lowest";d:11200000;s:11:"order_count";i:1;s:6:"volume";i:1;}i:46;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2023-01-12";s:7:"highest";d:11200000;s:6:"lowest";d:11200000;s:11:"order_count";i:1;s:6:"volume";i:2;}i:47;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2023-01-15";s:7:"highest";d:11200000;s:6:"lowest";d:11200000;s:11:"order_count";i:1;s:6:"volume";i:5;}i:48;O:8:"stdClass":6:{s:7:"average";d:11200000;s:4:"date";s:10:"2023-01-18";s:7:"highest";d:11200000;s:6:"lowest";d:11200000;s:11:"order_count";i:2;s:6:"volu"
[14/05/2023 19:49:46] Stack trace: #0 /data/www/evemyadmin/web/vendor/eveseat/eseye/src/Eseye.php(245): Seat\Eseye\Cache\FileCache->get()
#1 /data/www/evemyadmin/web/class/EVEOnline/ESI/EsiFactory.php(189): Seat\Eseye\Eseye->invoke()

The file content looks truncated leading to an error while unserializing.

Because the unserialize return false in case of error AND throw a E_NOTICE error, we need to handle this correctly and properly. Yet, we don't have, in our case, the need to serialize(false) so ignoring error from the unserialize method and only checking if the result is false should be enough.

I've updated my PR accordingly.

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

Successfully merging this pull request may close these issues.

2 participants