Skip to content

tests: (lslcoks) insert a sleep between taking a lock and running lslocks#2633

Merged
karelzak merged 1 commit into
util-linux:masterfrom
masatake:lslocks-issue-2624-2
Dec 8, 2023
Merged

tests: (lslcoks) insert a sleep between taking a lock and running lslocks#2633
karelzak merged 1 commit into
util-linux:masterfrom
masatake:lslocks-issue-2624-2

Conversation

@masatake

@masatake masatake commented Dec 7, 2023

Copy link
Copy Markdown
Member

Close #2624.

It appears that there is a time lag between locking and its visibility in /proc/locks. See the unstbale results of errors I observed in #2629.

…ocks

Close util-linux#2624.

It appears that there is a time lag between locking and its visibility
in /proc/locks.  See the unstbale results of errors I observed in
util-linux#2629.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
@masatake

masatake commented Dec 7, 2023

Copy link
Copy Markdown
Member Author

@karelzak Could you consider merging this as a solution for #2624?

This is not an ideal solution but #2624 becomes a show-stopper in the other pull requests.

@karelzak karelzak merged commit 75f9816 into util-linux:master Dec 8, 2023
@karelzak

karelzak commented Dec 8, 2023

Copy link
Copy Markdown
Collaborator

It is nothing unusual that userspace is faster than the kernel. Frankly, I do not see any elegant way to resolve it.

@t-8ch

t-8ch commented Dec 8, 2023

Copy link
Copy Markdown
Member

Isn't the problem that the coproc is not yet ready setting up the locks while the rest of the testing is already checking if it's there?

Some synchronization should help.
Either mkfds $ARGS -- $TESTCOMMAND, which would be nice but I'm not sure if this works together with the bash code blocks.
Or mkfds writes to the pipe that is set up by coproc and the testcommand waits for this write.
Or we keep the sleep :-)

@masatake

masatake commented Dec 8, 2023

Copy link
Copy Markdown
Member Author

Or mkfds writes to the pipe that is set up by coproc and the testcommand waits for this write.

mkfds works as you wrote.

mkfds prints its PID after taking the lock as specified in its cmdline. Test cases use 'read' built-in to get the PID from the coproc.

@masatake

masatake commented Dec 8, 2023

Copy link
Copy Markdown
Member Author

I'll inspect more in the future.

@karelzak

karelzak commented Dec 8, 2023

Copy link
Copy Markdown
Collaborator

Yes, coproc was also my first thing to blame, but from mkfds' code it seems it locks the file, and later it prints the PID, which the script is waiting for. I guess the read in the script waits for the PID ... or is it possible that it reads nothing from the pipe? Maybe the script can verify that $PID is > 0.

@t-8ch

t-8ch commented Dec 8, 2023

Copy link
Copy Markdown
Member

mkfds works as you wrote.

My bad. I should have read the code before speculating.

@masatake

masatake commented Dec 8, 2023

Copy link
Copy Markdown
Member Author

Yes, coproc was also my first thing to blame, but from mkfds' code it seems it locks the file, and later it prints the PID, which the script is waiting for. I guess the read in the script waits for the PID ... or is it possible that it reads nothing from the pipe? Maybe the script can verify that $PID is > 0.

I verified various possibilities in 7c958c6 .

I guess there is a time lag between locking and its visibility in /proc/locks (or locks field of /proc/$pid/fdinfo/$fd), though I cannot believe it.

I need a much smaller program that just (1) takes a lock, then (2) prints the information about the lock extracted from /proc. If my guess is correct, the smaller program can reproduce it.

@t-8ch

t-8ch commented Dec 8, 2023

Copy link
Copy Markdown
Member

In the first log of #2629 (comment)
the first invocation of lslocks finds the log but then the second doesn't anymore.

Very weird.

masatake added a commit to masatake/util-linux that referenced this pull request Apr 12, 2024
…g a /proc/[0-9]* fails

If a process ($pid) taking a lock is gone while running lslocks,
gathering per process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per process information.

As a result of the original behavior, tests/ts/lslocks/lslocks failed
rarely in the environment where multiple test cases simultaneously.

Close util-linux#2624 again.
See also util-linux#2633.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake added a commit to masatake/util-linux that referenced this pull request Apr 12, 2024
…g a /proc/[0-9]* fails

If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.

As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in the environment where multiple test cases simultaneously.

Close util-linux#2624 again.
See also util-linux#2633.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake added a commit to masatake/util-linux that referenced this pull request Apr 12, 2024
…g a /proc/[0-9]* fails

If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.

As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in an environment where multiple test cases ran simultaneously.

Close util-linux#2624 again.
See also util-linux#2633.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
masatake added a commit to masatake/util-linux that referenced this pull request Apr 16, 2024
…g a /proc/[0-9]* fails

If a process ($pid) taking a lock is gone while running lslocks,
gathering per-process information for the process may fail in opening
/proc/$pid. Though lslocks should work with incomplete information,
the original code stopped gathering per-process information for the
other processes.

As a result of the original behavior, tests/ts/lslocks/lslocks really
failed in an environment where multiple test cases ran simultaneously.

Close util-linux#2624 again.
See also util-linux#2633.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
(cherry picked from commit 20df923)
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.

lslocks: failed test

3 participants