Post by supak111 » Thu Feb 09, 2023 4:33 am

Hey boys and girls have a few questions here... moved my shared hosting and started to see this error sometimes:

Code: Select all

PHP Warning:  unlink(/storage/session//sess_a7ded8077a7978546b30d1f3c1): No such file or directory in /public_html/system/library/session/file.php on line 72
QUESTION 1) Any way to figure out why now? Hosting is very similar, more resources, kept the same PHP version 7.2
QUESTION 2) Why are there 2 forward slashes "//" in the error between word: session AND sess_a*.... Is this a concern?

I appreciate any input you guys can provide

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by paulfeakins » Thu Feb 09, 2023 6:14 pm

This vQmod should fix it ...

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
<id>filesystem session/cache unlink fix (backported from oc4)</id>
<author>joe@antropy</author>

<file name="system/library/cache/file.php,system/library/session/file.php">
	<operation>
		<search position="replace"><![CDATA[
			unlink($file);
		]]></search>
		<add trim="true"><!--php--><![CDATA[
			if (!@unlink($file)) {
				clearstatcache();
			}
		]]></add>
	</operation>
</file>
</modification>

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Guru Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by ADD Creative » Thu Feb 09, 2023 6:44 pm

1. Is usually caused by a race condition between two processes trying to delete the same file. If you are getting a lot, it could be your new server hosting has bad settings for session.gc_divisor or session.gc_probability.

2. The double / is this issue. Which the fix was sadly rejected for the 3.0.x.x_Maintenance.
https://github.com/opencart/opencart/pull/10536

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Fri Feb 10, 2023 9:10 am

Ok so I converted this mod to OCmod, I only use OCmods on my website.
Let me know if you guys see anything wrong with my conversion please

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <name>filesystem session/cache unlink fix (backported from oc4)</name>
    <code>filesystem session/cache unlink fix (backported from oc4)</code>
    <version>1.0</version>
    <author>joe@antropy</author>
    <link>https://forum.opencart.com/viewtopic.php?p=853516</link>
    <file path="system/library/cache/file.php,system/library/session/file.php">
        <operation>
            <search>
                <![CDATA[
                    unlink($file);
                ]]>
            </search>
            <add position="replace">
                <![CDATA[
                    if (!@unlink($file)) {
			clearstatcache();
		    }
		]]>
            </add>
        </operation>
    </file>
</modification>

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by by mona » Fri Feb 10, 2023 12:37 pm

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<modification>
    <name>filesystem session/cache unlink fix (backported from oc4)</name>
    <code>filesystem session/cache unlink fix (backported from oc4)</code>
    <version>1.0</version>
    <author>joe@antropy</author>
    <link>https://forum.opencart.com/viewtopic.php?p=853516</link>
    <file path="system/library/cache/file.php|system/library/session/file.php">
        <operation>
            <search><![CDATA[
                    unlink($file);
                ]]></search>
            <add position="replace"><![CDATA[
                    if (!@unlink($file)) {
		    clearstatcache();
		    		}
			]]></add>
        </operation>
    </file>
</modification>
remember to clear cache

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by ADD Creative » Fri Feb 10, 2023 6:18 pm

supak111 wrote:
Fri Feb 10, 2023 9:10 am
Ok so I converted this mod to OCmod, I only use OCmods on my website.
Let me know if you guys see anything wrong with my conversion please
The clearstatcache() is actually unneeded as unlink clears it anyway, so just the following will do.

Code: Select all

@unlink($file);
However, this is just hiding the error. As I have already stated if you are seeing a lot of unlink errors with the session files then this could point to another issue. Session file are only deleted in a small percentage of requests. You don't want this happening every request as it could slow things down.

Use phpinfo() and check the settings for session.gc_divisor or session.gc_probability.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by JNeuhoff » Fri Feb 10, 2023 8:24 pm

ADD Creative wrote:
Thu Feb 09, 2023 6:44 pm
2. The double / is this issue. Which the fix was sadly rejected for the 3.0.x.x_Maintenance.
https://github.com/opencart/opencart/pull/10536
You are right. I am not sure why Daniel rejected it. I have now added your fix to the 3.0.x.x_Maintenance, too. It's already fixed in the master branch.

Export/Import Tool * SpamBot Buster * Unused Images Manager * Instant Option Price Calculator * Number Option * Google Tag Manager * Survey Plus * OpenTwig


User avatar
Guru Member

Posts

Joined
Wed Dec 05, 2007 3:38 am


Post by ADD Creative » Fri Feb 10, 2023 8:54 pm

JNeuhoff wrote:
Fri Feb 10, 2023 8:24 pm
ADD Creative wrote:
Thu Feb 09, 2023 6:44 pm
2. The double / is this issue. Which the fix was sadly rejected for the 3.0.x.x_Maintenance.
https://github.com/opencart/opencart/pull/10536
You are right. I am not sure why Daniel rejected it. I have now added your fix to the 3.0.x.x_Maintenance, too. It's already fixed in the master branch.
Thanks. I suspect it was closed due to it already being fixed in the master.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Tue Feb 14, 2023 5:43 am

How many unlink errors is too many? I only see 1 every maybe 3 days right now. I though I saw way more first few days of switching hosting

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Tue Feb 14, 2023 6:25 am

It would depend on how busy your site is. 1 every 3 day isn't much if the site was very busy. But if you site only gets 1 visit a day it's a lot, but probably not any issue anyway.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by by mona » Wed Feb 15, 2023 1:59 am

Issue is OC lets individual arbitrary requests handle these housekeeping activities which means they are likely to clash, apart from the added response times.
Housekeeping activities like session gc, clearing cart entries, etc. would be better performed by a dedicated job.

DISCLAIMER:
You should not modify core files .. if you would like to donate a cup of coffee I will write it in a modification for you.


https://www.youtube.com/watch?v=zXIxDoCRc84


User avatar
Expert Member

Posts

Joined
Mon Jun 10, 2019 9:31 am

Post by supak111 » Sat Feb 18, 2023 8:14 am

I usually get 150-250 unique visitors a day...

Ok so for 2 3 days I had no "unlink" errors, then today I got 9!

Also today I had addition of: filemtime(): stat failed... before the unlink

PS the double slash session error was fixed at this link below, not sure if it will fix filemtime() error?
https://github.com/opencart/opencart/pu ... 10b4906066

Code: Select all

PHP Warning:  filemtime(): stat failed for /home/***/storage/session//sess_b6a4ae8c99932725dec8841721 in /home/***/public_html/system/library/session/file.php on line 71
PHP Warning:  unlink(/home/***/storage/session//sess_b6a4ae8c99932725dec8841721): No such file or directory in /home/***/public_html/system/library/session/file.php on line 72

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Sat Feb 18, 2023 8:36 pm

What are your PHP settings for session.gc_divisor or session.gc_probability. Use phpinfo() to check them.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Sun Feb 19, 2023 1:47 am

ADD Creative wrote:
Sat Feb 18, 2023 8:36 pm
What are your PHP settings for session.gc_divisor or session.gc_probability. Use phpinfo() to check them.
Hey all 4 settings for both of those show: 0 (zero)

What should it be? I'm on shared hosting, not sure if I have the ability to change this even

PS) I just realized my php.ini file has this set: session.save_path = "/var/cpanel/php/sessions/ea-php56"
but the sessions are actually saved to /home/***/storage/session

Should I change this to: session.save_path = "/home/***/storage/session"

PS #2) Just compared the php.ini file from my old host to now host and they are totally different even though I had the site restore from the other host. Not sure why they are so different when it should have been a exact copy
Last edited by supak111 on Sun Feb 19, 2023 3:48 am, edited 1 time in total.

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Sun Feb 19, 2023 2:57 am

That could be the cause. With them both set to zero will mean the session garbage collection will be done on every request, increasing the chance of a race condition.

Try setting session.gc_probability to 1 and session.gc_divisor to 100.

OpenCart uses it own session location.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Sun Feb 19, 2023 8:39 am

ADD Creative wrote:
Sun Feb 19, 2023 2:57 am
That could be the cause. With them both set to zero will mean the session garbage collection will be done on every request, increasing the chance of a race condition.

Try setting session.gc_probability to 1 and session.gc_divisor to 100.

OpenCart uses it own session location.
Ok I added my code below to php.ini but its still shows 0/zero in phpinfo.php... I take it I have to talk to tech support to change this..
session.gc_probability = 1;
session.gc_divisor = 100;

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm

Post by ADD Creative » Sun Feb 19, 2023 7:40 pm

Some hosts don't use the php.ini and you will have to set somewhere else. So it is best to ask your host how to change them.

Some host even perform the PHP garbage collection a different way and you can't change them.

You could also just changed the following line.
https://github.com/opencart/opencart/bl ... le.php#L56
To.

Code: Select all

$gc_divisor = 100;

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by supak111 » Mon Feb 20, 2023 5:42 am

Thanks for all your help everyone.

This forum should really add "LIKES" for posts ツ

~ OC 3.0.3.2 and OCmods only ~


User avatar
Active Member

Posts

Joined
Fri Feb 13, 2015 12:09 pm
Who is online

Users browsing this forum: Bing [Bot] and 263 guests