summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-10-25 07:10:03 -0700
committerGitHub <noreply@github.com>2019-10-25 07:10:03 -0700
commitebeb1ed62f8ac2a765213d872811eac7bac101c1 (patch)
tree9b64d785de2633fea52629acda00ec93783758b1
parentdbee91f7f1616113e21ebc5e186f0f66bfc21a9c (diff)
downloadspack-ebeb1ed62f8ac2a765213d872811eac7bac101c1.tar.gz
spack-ebeb1ed62f8ac2a765213d872811eac7bac101c1.tar.bz2
spack-ebeb1ed62f8ac2a765213d872811eac7bac101c1.tar.xz
spack-ebeb1ed62f8ac2a765213d872811eac7bac101c1.zip
bugfix: reindexing is not necessary for DB v0.9.3 to v5 upgrade (#13434)
reindexing takes a significant amount of time, and there's no reason to do it from DB version 0.9.3 to version 5. The only difference is that v5 can contain "deprecated_for" fields. - [x] Add a `_skip_reindex` list at the start of `database.py` - [x] Skip the reindex for upgrades in this list. The new version will just be written to the file the first time we actually have to write the DB out (e.g., after an install), and reads will still work fine.
-rw-r--r--lib/spack/spack/database.py28
1 files changed, 25 insertions, 3 deletions
diff --git a/lib/spack/spack/database.py b/lib/spack/spack/database.py
index 0ada7faa4c..022a2d3871 100644
--- a/lib/spack/spack/database.py
+++ b/lib/spack/spack/database.py
@@ -51,9 +51,20 @@ _db_dirname = '.spack-db'
# DB version. This is stuck in the DB file to track changes in format.
# Increment by one when the database format changes.
-# versions before 5 were not integers
+# Versions before 5 were not integers.
_db_version = Version('5')
+# For any version combinations here, skip reindex when upgrading.
+# Reindexing can take considerable time and is not always necessary.
+_skip_reindex = [
+ # reindexing takes a significant amount of time, and there's
+ # no reason to do it from DB version 0.9.3 to version 5. The
+ # only difference is that v5 can contain "deprecated_for"
+ # fields. So, skip the reindex for this transition. The new
+ # version is saved to disk the first time the DB is written.
+ (Version('0.9.3'), Version('5')),
+]
+
# Timeout for spack database locks in seconds
_db_lock_timeout = 120
@@ -486,8 +497,19 @@ class Database(object):
if version > _db_version:
raise InvalidDatabaseVersionError(_db_version, version)
elif version < _db_version:
- self.reindex(spack.store.layout)
- installs = dict((k, v.to_dict()) for k, v in self._data.items())
+ if not any(
+ old == version and new == _db_version
+ for old, new in _skip_reindex
+ ):
+ tty.warn(
+ "Spack database version changed from %s to %s. Upgrading."
+ % (version, _db_version)
+ )
+
+ self.reindex(spack.store.layout)
+ installs = dict(
+ (k, v.to_dict()) for k, v in self._data.items()
+ )
def invalid_record(hash_key, error):
msg = ("Invalid record in Spack database: "