Hello All,
I have written a code which uses Parallel ForkManager, which internally uses flock EX on a certain lock file in the system to synchronize all the threads while making DB requests.
Each threads have their own DB handler.

Somehow, the program which works for dev env, results into deadlock for the production environment. Nothing has changed in code.

I am creating 4 threads( basically process) using Parallel::ForkManager and wait for each of them to complete before the program exists.

The threads internally uses the following code to lock and unlock the file.

Code:
package Obj;

use Parallel::ForkManager;
sub main {

...# Process are started
$pm->start;
$new = Obj1->new();
$new->main();
....
$pm->wait_all_children;
....
}

package Obj1;

use FCntl qw(EFAULT :flock);

sub main {
....
sysopen(LOCKFILE, $file_name, O_RDONLY) or warn "Could not open file $!";
.....
}

sub getLock {
while(!flock(LOCKFILE, LOCK_EX| LOCK_NB) {
sleep(1);
}
}

sub releaseLock {
flock(LOCKFILE, LOCK_UN);
}

many methods of this object internally call the getLock and realeaseLock methods.

Kindly help to let me know where I am doing with trying to work the threads synchronously.