in reply to Re^4: Net::SFTP::Foreign works intermittently
in thread Net::SFTP::Foreign works intermittently

Do all the tasks involve connecting to the same server with the same authentication credentials? or are there several servers or credential settings?

How does Gearman Perl workers run at the OS level? are they threads inside some master process or are they different processes?

There could be some race condition on the PTY allocation as performed by IO::Pty. Try the strace thing.

Replies are listed 'Best First'.
Re^6: Net::SFTP::Foreign works intermittently
by JustPerl (Initiate) on Jun 17, 2014 at 11:19 UTC
    Yes, all the tasks are connecting to the same server with the same authentication credentials. And each Gearman worker runs in its own process. Can you tell me on how to run the strace thing? any examples.
      How many workers are you running in parallel?

      OpenSSH server has a configuration directive (MaxStartups) which allows to limit the number of not-yet-authorized connections. The default value is 10.

      Regarding strace, as root run:

      echo 0 > /proc/sys/kernel/yama/ptrace_scope
      Then you can attach strace processes to your workers adding the following code to them:
      system "strace -f -o /tmp/strace.$$.out -p $$ &";
      That will dump all the OS calls to the file strace.$$.out. There, you should be able to see the Perl process writing the password to the master pty side and the ssh process reading it from the slave side.
      Could you try to reproduce the problem with some variation of the script here?