summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Weimer <fw@deneb.enyo.de>2011-05-07 12:56:12 +0000
committerFlorian Weimer <fw@deneb.enyo.de>2011-05-07 12:56:12 +0000
commit0e2ea7a1aa4398ae0260e03bbf0503670c9ecb87 (patch)
tree2ad6e1dd021a35981ed7684167d22c2e5422a13b
parent11359cb0a3eb1cbf8cba1b077a0e7e5fe374805f (diff)
security_db.DB: enable SQLite WAL mode
This means that we no longer have to copy the database file. git-svn-id: svn+ssh://svn.debian.org/svn/secure-testing@16645 e39458fd-73e7-0310-bf30-c45bca0a0e42
-rw-r--r--Makefile5
-rw-r--r--bin/tracker_service.py2
-rw-r--r--lib/python/security_db.py30
3 files changed, 11 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index dadda19283..3d30ad9e4f 100644
--- a/Makefile
+++ b/Makefile
@@ -16,10 +16,7 @@ STABLE = squeeze
TESTING = wheezy
all:
- rm -f data/security-new.db data/security-new.db.journal
- if test -e data/security.db; then cp data/security.db data/security-new.db; fi
- $(PYTHON) bin/update-db data/security-new.db
- mv data/security-new.db data/security.db
+ $(PYTHON) bin/update-db data/security.db
clean:
-rm -f data/security.db lib/python/test_security.db
diff --git a/bin/tracker_service.py b/bin/tracker_service.py
index 47d6b597d7..c74409fcb9 100644
--- a/bin/tracker_service.py
+++ b/bin/tracker_service.py
@@ -1280,6 +1280,6 @@ Debian bug number.'''),
return SPAN(contents, _class="dangerous")
def pre_dispatch(self):
- self.db.refresh()
+ pass
TrackerService(socket_name, db_name).run()
diff --git a/lib/python/security_db.py b/lib/python/security_db.py
index 314fa07ab5..922cec46c3 100644
--- a/lib/python/security_db.py
+++ b/lib/python/security_db.py
@@ -113,11 +113,19 @@ class DB:
self.name = name
self.db = apsw.Connection(name)
self.verbose = verbose
+ c = self.cursor()
+
+ # This gives us better performance (it's usually the file
+ # system block size). This must come first to be effective.
+
+ c.execute("PRAGMA page_size = 4096")
+
+ # Enable WAL. This means that updates will not block readers.
+ c.execute("PRAGMA journal_mode = WAL")
self.schema_version = 22
self._initFunctions()
- c = self.cursor()
for (v,) in c.execute("PRAGMA user_version"):
if v == 0:
self.initSchema()
@@ -138,27 +146,12 @@ class DB:
% (self.schema_version, v)
raise SchemaMismatch, `v`
self._initViews(c)
- # Database has been created at this point. Small race
- # condition here (the already opened database might refer
- # to an older file).
- self.__stat = os.stat(self.name)
return
assert False
def __del__(self):
self.db.close()
- def refresh(self):
- """Checks if the database file is still the same and reopens
- it if necessary."""
- current = os.stat(self.name)
- if os.path.samestat(self.__stat, current):
- return
- self.__stat = current
- self.db = apsw.Connection(self.name)
- self._initFunctions()
- self._initViews(self.cursor())
-
def cursor(self):
"""Creates a new database cursor.
@@ -188,11 +181,6 @@ class DB:
"""Creates the database schema."""
cursor = self.cursor()
- # This gives us better performance (it's usually the file
- # system block size). This must come first to be ffective.
-
- cursor.execute("PRAGMA page_size = 4096")
-
# Set the schema version to an invalid value which is
# different from zero. We can use this to detect a partially
# created schema.

© 2014-2024 Faster IT GmbH | imprint | privacy policy