Bug #32282

typo3temp/locks warning. unlink function returns warning

Added by Razakanirina over 1 year ago. Updated 9 months ago.

Status:Resolved Start date:2011-12-03
Priority:Should have Due date:
Assignee:- % Done:

100%

Category:-
Target version:-
TYPO3 Version:4.5 Complexity:
PHP Version:5.3
Votes: 0

Description

php unlink() function returns a warning when the file does not exist.

Obtained warning:
---
Core: Error handler (FE): PHP Warning: unlink(/.../.../typo3temp/locks/107c9b0324ec9db67812eb6af3e78732) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in /usr/local/src/typo3/typo3_src-4.5.8/t3lib/class.t3lib_lock.php line 210

We should test the $this->resource variable by file_exists() php function before unlinking.

if (unlink($this->resource) == FALSE) {

T3X_user_locktest-0_0_0-z-201112201702.t3x (1.8 kB) Helmut Hummel, 2011-12-20 17:05


Related issues

related to Core - Bug #19112: unlink of non existing lockfiles generates warnings in fr... Closed 2008-07-16
duplicates Core - Bug #24342: t3lib_lock still sometimes has a race condition on deleti... Accepted 2010-12-15

Associated revisions

Revision 6a9e789b
Added by Markus Klein about 1 year ago

[BUGFIX] unlink issues warnings for lock files

t3lib_lock issues warnings for non-existent lock files.

Change-Id: I069f6d9bdb6e84e7436e81b9fdf94d14ab6065ec
Fixes: #32282
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/7052
Tested-by: Razakanirina
Reviewed-by: Dmitry Dulepov
Tested-by: Dmitry Dulepov
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader

Revision 9ea4e973
Added by Markus Klein about 1 year ago

[BUGFIX] unlink issues warnings for lock files

t3lib_lock issues warnings for non-existent lock files.

Change-Id: I069f6d9bdb6e84e7436e81b9fdf94d14ab6065ec
Fixes: #32282
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/9612
Reviewed-by: Steffen Ritter
Tested-by: Steffen Ritter

Revision 731d5472
Added by Markus Klein 10 months ago

[BUGFIX] unlink issues warnings for lock files

t3lib_lock issues warnings for non-existent lock files.

Change-Id: I88fe35d5d21fb4137b32ca34d6ed16c091d40431
Fixes: #32282
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/12832
Reviewed-by: Marcus Schwemer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

Revision 1e11fd1d
Added by Markus Klein 10 months ago

[BUGFIX] unlink issues warnings for lock files

t3lib_lock issues warnings for non-existent lock files.

Change-Id: I55df9938cf56825cd808195f74f10582d2ecedad
Fixes: #32282
Releases: 4.7, 4.6, 4.5, 4.4
Reviewed-on: http://review.typo3.org/12831
Reviewed-by: Marcus Schwemer
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn

History

Updated by Gerrit Code Review over 1 year ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/7052

Updated by Xavier Perseguers over 1 year ago

I've seen this behaviour and I'm currently trying to figure out what the cause is. I suspect some race condition.

Updated by Björn Pedersen over 1 year ago

This is a race condition reported here already:
http://forge.typo3.org/issues/24342

Updated by Xavier Perseguers over 1 year ago

There is indeed a problem that appears when the lock file could not be acquired, as reported in this syslog (after slightly modifying Core to add additional information):

05-12-11 15:24 - cms: Locking: Failed to acquire lock: Lock file could not be created
(/path/to/typo3temp/locks/f288221509d8f33b8e85fbfd25731733)
05-12-11 15:24 - Core: Error handler (FE): PHP Warning: unlink(/path/to/typo3temp/locks/
f288221509d8f33b8e85fbfd25731733) [<a href='function.unlink'>function.unlink</a>]: No such
file or directory in /path/to/t3lib/class.t3lib_lock.php line 21

The non-acquired lock-file is then "unlinked" by taking for granted that it exists. By quickly digging into the code, I'd say that fixing that would require quite some refactoring of t3lib_lock, refactoring that is supposed to happen with #24342 but was forgotten (as not pushed forwards) for 4.6, thus hopefully something for 4.7.

Anyway, I would suggest to simply test for file existence before unlinking it but not hide the warning with an @ sign in front of unlink.

Updated by Razakanirina over 1 year ago

Does testing if file exists solve the race condition problem? Does it related to the php unlink() function?

Updated by Helmut Hummel over 1 year ago

  • Status changed from Under Review to Needs Feedback

For those who have problems with the unlink warning message:

What is your max_execution_time setting?

The only reace condition which is clearly there is because of deleting stale lock files.

Updated by Helmut Hummel over 1 year ago

I added a small extension to reproduce the problem.

Install it, then execute the following command line:

wget -qO- "http://typo3.dev/index.php?eID=locktest&number=first" & sleep 2; wget -qO- "http://typo3.dev/index.php?eID=locktest&number=second" 

The problem will occur, when the max_execution_time is relatively low (forced to be 1 second in the extension), but the request itself takes longer than the max_execution_time

This may well happen because max_execution_time only reflects the PHP script execution times but excludes the time that is consumed by single commands (like sleep or other system commands)

Updated by Xavier Perseguers over 1 year ago

What about adding the @ sign in front of unlink instead of testing with file_exists. I'd say that even if not "that clean", it will prevent perform 2 accesses for the file system in most cases...

Updated by Gerrit Code Review about 1 year ago

  • Status changed from Needs Feedback to Under Review

Patch set 1 for branch TYPO3_4-7 has been pushed to the review server.
It is available at http://review.typo3.org/9612

Updated by Markus Klein about 1 year ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Updated by Gerrit Code Review 10 months ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_4-5 has been pushed to the review server.
It is available at http://review.typo3.org/12831

Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch TYPO3_4-6 has been pushed to the review server.
It is available at http://review.typo3.org/12832

Updated by Markus Klein 10 months ago

  • Status changed from Under Review to Resolved

Updated by Gerrit Code Review 9 months ago

  • Status changed from Resolved to Under Review

Updated by Oliver Hader 9 months ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF