about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-12-11T10·49+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-12-11T10·49+0100
commit772778c0eced8f8d63bfe6b1e9801ad6aada65bf (patch)
treeb93190ac1e556060923024d05cf79cfbf33a97f8 /src/libstore/local-store.cc
parente087bfef5f36f309b1c8d01bfe297e4cf4decb34 (diff)
On SQLITE_BUSY, wait a random amount of time
If all contending processes wait a fixed amount of time (100 ms),
there is a good probability that they'll just collide again.
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index b4fc64d712fa..26b4cfd8c234 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -48,7 +48,7 @@ static void throwSQLiteError(sqlite3 * db, const format & f)
 #if HAVE_NANOSLEEP
         struct timespec t;
         t.tv_sec = 0;
-        t.tv_nsec = 100 * 1000 * 1000; /* 0.1s */
+        t.tv_nsec = (random() % 100) * 1000 * 1000; /* <= 0.1s */
         nanosleep(&t, 0);
 #else
         sleep(1);