Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Silbe <sascha-pgp@silbe.org>2011-05-14 17:49:10 (GMT)
committer Sascha Silbe <sascha-pgp@silbe.org>2011-05-14 18:06:02 (GMT)
commitb42b8482b191f4f509d5418242e7a8c00e3418f9 (patch)
tree731cbd2943eeefd66792fc4e2fba9f428984fea5
parent521c0b0de1ff8b65a01cd8432ac4a11899cae590 (diff)
Retry opening the Xapian database if another process still has the lock
This should help with situations where the new gdatastore process is already starting up (on a new session bus) while the old one is still busy shutting down (see also: SL#1257).
-rw-r--r--gdatastore/index.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/gdatastore/index.py b/gdatastore/index.py
index c93f5b3..35491bf 100644
--- a/gdatastore/index.py
+++ b/gdatastore/index.py
@@ -19,6 +19,7 @@ Gdatastore metadata index interface
import logging
import os
import sys
+import time
import xapian
from xapian import Document, Enquire, Query, WritableDatabase
@@ -320,8 +321,17 @@ class Index(object):
database.close()
def _migrate(self):
- self._database = WritableDatabase(self._base_dir,
- xapian.DB_CREATE_OR_OPEN)
+ for try_count in range(10):
+ try:
+ self._database = WritableDatabase(self._base_dir,
+ xapian.DB_CREATE_OR_OPEN)
+ except xapian.DatabaseLockError:
+ logging.error("Couldn't lock Xapian database (try #%d)",
+ try_count)
+ time.sleep(1)
+ else:
+ break
+
version = int(self._database.get_metadata('gdatastore_version'))
if version > _CURRENT_VERSION: