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.

package Obj;

use Parallel::ForkManager;
sub main {

...# Process are started
$new = Obj1->new();

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) {

sub releaseLock {

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.