LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   duplicate ids in /proc/locks (https://www.linuxquestions.org/questions/linux-general-1/duplicate-ids-in-proc-locks-798919/)

robmoser 03-30-2010 11:09 AM

duplicate ids in /proc/locks
 
Hi All,

Red Hat Enterprise Linux Server release 5.4 (Tikanga)
2.6.18-164.11.1.el5xen (Xen release for virtualisation)

I'm trying to track down a problem with a utility that used to work and now hangs indefinitely. Since its hanging, I suspected a locking problem, and went to have a look for the process ids in /proc/locks; I get:

148: FLOCK ADVISORY WRITE 30279 ca:21:49153 0 EOF
148: -> FLOCK ADVISORY READ 30282 ca:21:49153 0 EOF

Now as near as I can tell this shouldn't be my problem, since the two ADVISORY locks - one READ and one WRITE - shouldn't conflict with one another. But I'd like to understand it all the same. I haven't been able to find any kind of definitive guide for the format of /proc/locks entries, but what I did find in the manuals specifically states:

"Each lock has its own line which starts with a unique number. "

Which is obviously not true; both of my lines start with the same number. Also, since most search engines don't seem to play nicely with symbols, I can't find any reference to what the "->" means. Can anyone explain? Or point me to a good reference?

Thanks much,

- rob.

codedr 04-03-2010 05:13 AM

man 5 proc

As for your 'hanging process', I would use strace to find what resource it is trying to acquire or wait on.

strace -o /var/tmp/foo myProg
You may need to use -f, ymmv.

robmoser 04-05-2010 10:54 AM

man 5 proc has this to say about /proc/locks:
Quote:

/proc/locks
This file shows current file locks (flock(2) and fcntl(2)) and leases (fcntl(2)).
...and thats it. Not exactly a fount of information about the format. (I of course followed up on the man pages for the system calls, but none of them say anything about the format of the locks file.)

But strace is a useful one that I hadn't used before - thanks for the pointer.

MensaWater 04-05-2010 11:18 AM

Quote:

Originally Posted by codedr (Post 3922726)
man 5 proc

Before suggesting "man" you might want to review the man page you're talking about yourself to see if it includes the answer. Typically what I do is point out that man has the answer then quote the section or part of the section. In this case man did not have the answer.

jpv50 09-05-2013 11:02 AM

I'm replying to this because there is so little information about the format of /proc/locks

Your output clearly shows why you have deadlock, if only you knew how to read it.

148: FLOCK ADVISORY WRITE 30279 ca:21:49153 0 EOF
148: -> FLOCK ADVISORY READ 30282 ca:21:49153 0 EOF

The first line shows one lock (id. 148) held by process with pid 30279. This is a write lock.
The second line shows a process is waiting to acquire the lock. It's pid 30282 and the "->" shows it's waiting to acquire the lock. It wants a read lock.

You need to figure out why process 30279 is holding a write lock, blocking process 30282 which is waiting for a read lock.

I hope this is helpful to people searching for information on this subject.


All times are GMT -5. The time now is 04:56 AM.