sqlcache: initialize meta table last stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 27 Aug 2018 11:27:04 +0200
branchstable
changeset 4022 082b59126099
parent 4021 bebba5a5c82d
child 4023 f59b262400fb
sqlcache: initialize meta table last It turns out that pysqlite commit after each table creation. This commit is an hopeless attemps to make the caches more concurrent friendly.
hgext3rd/evolve/obsdiscovery.py
hgext3rd/evolve/stablerangecache.py
--- a/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 10:20:15 2018 +0200
+++ b/hgext3rd/evolve/obsdiscovery.py	Mon Aug 27 11:27:04 2018 +0200
@@ -328,6 +328,11 @@
 ### sqlite caching
 
 _sqliteschema = [
+    """CREATE TABLE obshashrange(rev     INTEGER NOT NULL,
+                                 idx     INTEGER NOT NULL,
+                                 obshash BLOB    NOT NULL,
+                                 PRIMARY KEY(rev, idx));""",
+    "CREATE INDEX range_index ON obshashrange(rev, idx);",
     """CREATE TABLE meta(schemaversion INTEGER NOT NULL,
                          tiprev        INTEGER NOT NULL,
                          tipnode       BLOB    NOT NULL,
@@ -335,11 +340,6 @@
                          obssize       BLOB    NOT NULL,
                          obskey        BLOB    NOT NULL
                         );""",
-    """CREATE TABLE obshashrange(rev     INTEGER NOT NULL,
-                                 idx     INTEGER NOT NULL,
-                                 obshash BLOB    NOT NULL,
-                                 PRIMARY KEY(rev, idx));""",
-    "CREATE INDEX range_index ON obshashrange(rev, idx);",
 ]
 _queryexist = "SELECT name FROM sqlite_master WHERE type='table' AND name='meta';"
 _clearmeta = """DELETE FROM meta;"""
--- a/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 10:20:15 2018 +0200
+++ b/hgext3rd/evolve/stablerangecache.py	Mon Aug 27 11:27:04 2018 +0200
@@ -88,10 +88,6 @@
 #############################
 
 _sqliteschema = [
-    """CREATE TABLE meta(schemaversion INTEGER NOT NULL,
-                         tiprev        INTEGER NOT NULL,
-                         tipnode       BLOB    NOT NULL
-                        );""",
     """CREATE TABLE range(rev INTEGER  NOT NULL,
                           idx INTEGER NOT NULL,
                           PRIMARY KEY(rev, idx));""",
@@ -107,6 +103,10 @@
     "CREATE INDEX subranges_index ON subranges (suprev, supidx);",
     "CREATE INDEX superranges_index ON subranges (subrev, subidx);",
     "CREATE INDEX range_index ON range (rev, idx);",
+    """CREATE TABLE meta(schemaversion INTEGER NOT NULL,
+                         tiprev        INTEGER NOT NULL,
+                         tipnode       BLOB    NOT NULL
+                        );""",
 ]
 _newmeta = "INSERT INTO meta (schemaversion, tiprev, tipnode) VALUES (?,?,?);"
 _updatemeta = "UPDATE meta SET tiprev = ?, tipnode = ?;"