1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-19 23:03:53 -04:00
nix/src
Eelco Dolstra d05bf04444 Treat SQLITE_PROTOCOL as SQLITE_BUSY
In the Hydra build farm we fairly regularly get SQLITE_PROTOCOL errors
(e.g., "querying path in database: locking protocol").  The docs for
this error code say that it "is returned if some other process is
messing with file locks and has violated the file locking protocol
that SQLite uses on its rollback journal files."  However, the SQLite
source code reveals that this error can also occur under high load:

  if( cnt>5 ){
    int nDelay = 1;                      /* Pause time in microseconds */
    if( cnt>100 ){
      VVA_ONLY( pWal->lockError = 1; )
      return SQLITE_PROTOCOL;
    }
    if( cnt>=10 ) nDelay = (cnt-9)*238;  /* Max delay 21ms. Total delay 996ms */
    sqlite3OsSleep(pWal->pVfs, nDelay);
  }

i.e. if certain locks cannot be not acquired, SQLite will retry a
number of times before giving up and returing SQLITE_PROTOCOL.  The
comments say:

  Circumstances that cause a RETRY should only last for the briefest
  instances of time.  No I/O or other system calls are done while the
  locks are held, so the locks should not be held for very long. But
  if we are unlucky, another process that is holding a lock might get
  paged out or take a page-fault that is time-consuming to resolve,
  during the few nanoseconds that it is holding the lock.  In that case,
  it might take longer than normal for the lock to free.
  ...
  The total delay time before giving up is less than 1 second.

On a heavily loaded machine like lucifer (the main Hydra server),
which often has dozens of processes waiting for I/O, it seems to me
that a page fault could easily take more than a second to resolve.
So, let's treat SQLITE_PROTOCOL as SQLITE_BUSY and retry the
transaction.

Issue NixOS/hydra#14.
2013-10-16 14:19:59 +02:00
..
boost * Install some headers in the right location. 2009-03-05 14:57:50 +00:00
bsdiff-4.3 Drop the externals directory 2012-03-18 23:54:57 +01:00
libexpr printStats(): Print the size of the symbol table in bytes 2013-10-08 15:37:08 +02:00
libmain Report OOM errors better 2013-10-02 14:34:36 +02:00
libstore Treat SQLITE_PROTOCOL as SQLITE_BUSY 2013-10-16 14:19:59 +02:00
libutil RestoreSink: Slightly reduce the number of concurrent FDs 2013-09-17 12:06:59 +00:00
nix-daemon Report OOM errors better 2013-10-02 14:34:36 +02:00
nix-env Remove stray debug line 2013-09-06 17:20:19 +02:00
nix-hash When ‘--help’ is given, just run ‘man’ to show the manual page 2012-10-03 16:40:09 -04:00
nix-instantiate Work on Values instead of Exprs 2013-09-03 13:17:51 +00:00
nix-log2xml * Emit warning='1' or error='1' attributes for lines marked as 2010-03-05 12:54:58 +00:00
nix-setuid-helper Templatise tokenizeString() 2012-09-19 15:43:23 -04:00
nix-store nix-store --export: Export paths in topologically sorted order 2013-05-23 14:55:36 -04:00
Makefile.am Rename nix-worker to nix-daemon 2012-10-03 17:59:23 -04:00