0

I’ve left my Tor relay (run on an AWS EC2 instance, Xenial Xerius Ubuntu) alone for a few days, and it operated for a few days. The relay then started counting downtime, and the “last seen” timestamp on the Tor metrics website said it was last seen a few days ago. I was poking around with the command line, and I got a message with log level warn saying “It looks like another Tor process is running with the same data directory. Waiting 5 seconds to see if it goes away.”. Then a message with log level info appeared saying “tor_lockfile_lock(): Locking “/home/ubuntu/.tor/lock”, then an err message saying “No, it’s still there. Exiting”. Another err message followed saying “set_options(): Bug: acting on config options left us in a broken state. Dying. (on Tor 0.3.3.7 )”, then a final err message saying “Reading config failed—see warnings above.”. I looked at the source code, and I found this code block:

static tor_lockfile_t *lockfile = NULL;

int
try_locking(or_options_t *options, int err_if_locked)
{
  if (lockfile)
    return 0;
  else {
    char *fname = options_get_datadir_fname2_suffix(options, "lock",NULL,NULL);
    int already_locked = 0;
    tor_lockfile_t *lf = tor_lockfile_lock(fname, 0, &already_locked);
    tor_free(fname);
    if (!lf) {
      if (err_if_locked && already_locked) {
        int r;
        log_warn(LD_GENERAL, "It looks like another Tor process is running "
                 "with the same data directory.  Waiting 5 seconds to see "
                 "if it goes away.");
#ifndef WIN32
        sleep(5);
#else
        Sleep(5000);
#endif
        r = try_locking(options, 0);
        if (r<0) {
          log_err(LD_GENERAL, "No, it's still there.  Exiting.");
          exit(0);
        }
        return r;
      }
      return -1;
    }
    lockfile = lf;
    return 0;
  }
}

Here's the Tor metrics page link for my relay: https://metrics.torproject.org/rs.html#details/B169906909476519CF94B87812C231516FBA2D95

What's going on?

2 Answers 2

0

I got this answer from a colleague:

It seems that the cause is running multiple Tor instances which share the same data directory (~/.tor by default). The lock file in that directory will prevent you from doing so. Did you have more than one Tor process running on the VM? If you want multiple Tor processes for some reason, perhaps you need to run each process using a different data directory.

You can set the DataDirectory in the torrc files as shown in this post.

https://stackoverflow.com/questions/14321214/how-to-run-multiple-tor-processes-at-once-with-different-exit-ips

0

The result is as you've described in your answer, but the root of the problem is in Ubuntu's flaws. To avoid them - build Tor by hand from the sources with SystemD support and make a proper startup file. Do not rely on the binary packages under Ubuntu - there're even worse cases on flight

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .