Skip to content

wildcard-file: fix race between EOF and file deletion detection #160

Merged
alltilla merged 2 commits intoaxoflow:mainfrom
MrAnno:fix-wildcard-delete-race
Jun 13, 2024
Merged

wildcard-file: fix race between EOF and file deletion detection #160
alltilla merged 2 commits intoaxoflow:mainfrom
MrAnno:fix-wildcard-delete-race

Conversation

@MrAnno
Copy link
Contributor

@MrAnno MrAnno commented Jun 10, 2024

This patch fixes a "race condition" between the EOF and file deletion
detection of AxoSyslog when wildcard-file() is used.

If a file is written after being deleted (an application keeps an fd
open), or if these two events occur concurrently, nearly at the same
time, the file poller mechanism might schedule another read cycle while
the file has already been marked as fully read and deleted.

To avoid scheduling issues between the two checks, the following is done
from now on: We do not track the EOF state in the WildcardFileReader,
instead, when a file deletion notification is received, the poller will
be instructed to stop after reaching the next EOF, and only then will
AxoSyslog actually delete the reader instance.

Fixxes syslog-ng/syslog-ng#4989

MrAnno added 2 commits June 10, 2024 20:09
This patch fixes a "race condition" between the EOF and file deletion
detection of AxoSyslog when wildcard-file() is used.

If a file is written after being deleted (an application keeps an fd
open), or if these two events occur concurrently, nearly at the same
time, the file poller mechanism might schedule another read cycle while
the file has already been marked as fully read and deleted.

To avoid scheduling issues between the two checks, the following is done
from now on: We do not track the EOF state in the WildcardFileReader,
instead, when a file deletion notification is received, the poller will
be instructed to stop after reaching the next EOF, and only then will
AxoSyslog actually delete the reader instance.

Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
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