FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Cloning locks up when more than 3 at the same time. · Issue #364 · nodegit/nodegit · GitHub

Repository navigation

Cloning locks up when more than 3 at the same time.  #364

Description

Hello,

it seems that there is a problem with ssh agent support. this example works fine:

var remote = "https://github.com/nodegit/nodegit.git"
var git = require("nodegit");

var fs = require("fs");
var path = require("path");
function rmdirSync(path) {
    var files = [];
    if( fs.existsSync(path) ) {
        files = fs.readdirSync(path);
        files.forEach(function(file,index){
            var curPath = path + "/" + file;
            if(fs.lstatSync(curPath).isDirectory()) { // recurse
                rmdirSync(curPath);
            } else { // delete file
                fs.unlinkSync(curPath);
            }
        });
        fs.rmdirSync(path);
    }
}

function clone(to) {
    rmdirSync(to);
    return git.Clone.clone(remote, to).then(function () {
        console.log("ok!", to);
    }, function (err) {
        console.log("failed!", to, err);
    });
}

console.log("start");

clone("/tmp/nodegit-testA").then(function() {
    clone("/tmp/nodegit-testB").then(function() {
        clone("/tmp/nodegit-testC").then(function() {
            clone("/tmp/nodegit-testD").then(function() {
                clone("/tmp/nodegit-testE").then(function() {
                    for (var i = 0; i < 10; i++) {
                        var to = "/tmp/nodegit-test" + i;
                        console.log("start", i);
                        clone(to);
                    }
                });
            });
        });
    });
});

console.log("end");

output:

start
end
ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE
start 0
start 1
start 2
start 3
start 4
start 5
start 6
start 7
start 8
start 9
ok! /tmp/nodegit-test2
ok! /tmp/nodegit-test3
ok! /tmp/nodegit-test1
ok! /tmp/nodegit-test0
ok! /tmp/nodegit-test4
ok! /tmp/nodegit-test5
ok! /tmp/nodegit-test6
ok! /tmp/nodegit-test7
ok! /tmp/nodegit-test8
ok! /tmp/nodegit-test9

This is fine and expected, but when I switch to using ssh agent key :

return git.Clone.clone(remote, to, {
    remoteCallbacks: {
        credentials: function (url, userName) {
            return git.Cred.sshKeyFromAgent("");
        }
    }
}).then(function () {

(and a git ssh server) then nodegit can checkout one by one as before:

ok! /tmp/nodegit-testA
ok! /tmp/nodegit-testB
ok! /tmp/nodegit-testC
ok! /tmp/nodegit-testD
ok! /tmp/nodegit-testE

but will hang when called multiple times at once and never return. (No ok or failed messages for /tmp/nodegit-test0 - /tmp/nodegit-test9)

Direcotrys /tmp/nodegit-test0 to /tmp/nodegit-test3 are created:

find /tmp/nodegit-test0/
/tmp/nodegit-test0/
/tmp/nodegit-test0/.git
/tmp/nodegit-test0/.git/config
/tmp/nodegit-test0/.git/HEAD
/tmp/nodegit-test0/.git/description
/tmp/nodegit-test0/.git/info
/tmp/nodegit-test0/.git/info/exclude
/tmp/nodegit-test0/.git/hooks
/tmp/nodegit-test0/.git/hooks/README.sample
/tmp/nodegit-test0/.git/refs
/tmp/nodegit-test0/.git/refs/tags
/tmp/nodegit-test0/.git/refs/heads
/tmp/nodegit-test0/.git/objects
/tmp/nodegit-test0/.git/objects/pack
/tmp/nodegit-test0/.git/objects/info

but there is no working copy.

Can anyone give me he hint what I'm doing wrong? it is not allowed to call multiple checkout commands at the same time?

Activity

  1. johnhaley81 commented on Jan 22, 2015

    Collaborator

    I actually get the same thing with the first test (i.e. no remoteCallbacks). It makes the 0-3 directories and then just dies. Waited like 20 minutes and nothing happened. I even get the result when I use a super small repo.

    It seems like sending out those clone commands in parallel is causing them to go into some sort of thread locked state but even when I disable threading by removing this line I still get the same behavior.

    I'd say run this in series for right now. Something is definitely wrong with parallel cloning.

  2. maxkorp commented on Jan 30, 2015

    Collaborator

    Hrm, 3 is the magic good number on my machine. Even with very large repos, I can do 3 concurrent clones with no issue.

    With 4 repos, even with very small repos, it hangs regardless. Like @johnhaley81, it doesn't seem to matter regarding the remoteCallbacks.

  3. maxkorp commented on Jan 30, 2015

    Collaborator

    I reworked your example into a bit of a testbed, in case anyone else gets a chance to look at it.

    var size = "small"; // large or small
    var protocol = "https"; // https or ssh
    var howManyAsync = 3; // <=3 works, >=4 breaks
    
    var remotes = {
      small: {
        https: "https://github.com/nodegit/test2.git",
        ssh: "git@github.com:nodegit/test2.git"
      },
      large: {
        https: "https://github.com/nodegit/nodegit.git",
        ssh: "git@github.com:nodegit/nodegit.git"
      }
    };
    
    
    var nodegit = require("../..");
    var fse = require("fs-extra");
    var path = require("path");
    var Promise = require("nodegit-promise");
    
    var remote = remotes[size][protocol];
    
    function clone(to) {
      var opts = { ignoreCertErrors: 1 };
      if (protocol == "ssh") {
        opts.remoteCallbacks = {
          credentials: function (url, userName) {
            return git.Cred.sshKeyFromAgent(userName); // userName should be "git"
          }
        }
      }
    //    var opts = undefined;
      to = "/tmp/nodegit-test" + to;
      console.log("start ", to);
      fse.removeSync(to);
      return nodegit.Clone.clone(remote, to, opts).then(function () {
          console.log("ok!", to);
          return Promise.resolve();
      }, function (err) {
          console.log("failed!", to, err);
          return Promise.reject(err);
      });
    }
    
    console.log("start");
    
    clone("A")
      .then(function() {
        return clone("B")
      })
      .then(function() {
        return clone("C")
      })
      .then(function() {
        return clone("D")
      })
      .then(function() {
        return clone("E")
      })
      .then(function() {
        var promises = []
        for (var i = 0; i < howManyAsync; i++) {
          promises.push(clone(i));
        }
    
        return Promise.all(promises);
      })
      .then(function() {
        console.log("end GOOD");
      }, function() {
        console.log("end BAD");
      })
      .done(function() {
        console.log("end REGARDLESS");
      });
  4. drieks commented on Jan 30, 2015

    Author

    Are you sure that this is required? At last for SSH this seems to be ignored...

    return git.Cred.sshKeyFromAgent(userName); // userName should be "git"
    
  5. maxkorp commented on Jan 30, 2015

    Collaborator

    libgit2 docs don't specify, but I'd venture that if the values your passing to sshKeyFromAgent don't line up and it still works, it's hitting some default somehow.

  6. changed the title [-]ssh agent key and multiple checkouts[/-] [+]Cloning locks up when more than 3 at the same time. [/+] on Feb 4, 2015
  7. tbranyen commented on Feb 28, 2015

    Member

    This has been resolved via: #425

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL