From 235c381065220696388172c29a153d2b8962684e Mon Sep 17 00:00:00 2001 From: Matt Hicks Date: Wed, 20 Nov 2024 09:11:40 -0600 Subject: [PATCH] Fixes to LightDB upgrades --- core/src/main/scala/lightdb/LightDB.scala | 14 +++++--------- .../main/scala/lightdb/rocksdb/RocksDBStore.scala | 14 -------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/core/src/main/scala/lightdb/LightDB.scala b/core/src/main/scala/lightdb/LightDB.scala index 80a896fb..04759a7f 100644 --- a/core/src/main/scala/lightdb/LightDB.scala +++ b/core/src/main/scala/lightdb/LightDB.scala @@ -166,22 +166,18 @@ trait LightDB extends Initializable with FeatureSupport[DBFeatureKey] { dbInitialized: Boolean, stillBlocking: Boolean): Unit = upgrades.headOption match { case Some(upgrade) => - val continueBlocking = upgrades.exists(_.blockStartup) - if (!dbInitialized && !upgrade.applyToNew) { - appliedUpgrades.modify { set => - set + upgrade.label - } - doUpgrades(upgrades.tail, dbInitialized, continueBlocking) - } else if (stillBlocking && !continueBlocking) { + val runUpgrade = dbInitialized || upgrade.applyToNew + val continueBlocking = upgrades.exists(u => u.blockStartup && (dbInitialized || u.applyToNew)) + if (stillBlocking && !continueBlocking) { scribe.Platform.executionContext.execute(() => { - upgrade.upgrade(this) + if (runUpgrade) upgrade.upgrade(this) appliedUpgrades.modify { set => set + upgrade.label } doUpgrades(upgrades.tail, dbInitialized, continueBlocking) }) } else { - upgrade.upgrade(this) + if (runUpgrade) upgrade.upgrade(this) appliedUpgrades.modify { set => set + upgrade.label } diff --git a/rocksdb/src/main/scala/lightdb/rocksdb/RocksDBStore.scala b/rocksdb/src/main/scala/lightdb/rocksdb/RocksDBStore.scala index a5a14433..ea66d630 100644 --- a/rocksdb/src/main/scala/lightdb/rocksdb/RocksDBStore.scala +++ b/rocksdb/src/main/scala/lightdb/rocksdb/RocksDBStore.scala @@ -87,20 +87,6 @@ class RocksDBStore[Doc <: Document[Doc], Model <: DocumentModel[Doc]](directory: db.close() } - private def iteratorOld(rocksIterator: RocksIterator, value: Boolean = true): Iterator[Array[Byte]] = new Iterator[Array[Byte]] { - override def hasNext: Boolean = rocksIterator.isValid - - override def next(): Array[Byte] = try { - if (value) { - rocksIterator.value() - } else { - rocksIterator.key() - } - } finally { - rocksIterator.next() - } - } - private def iterator(rocksIterator: RocksIterator, value: Boolean = true): Iterator[Array[Byte]] = new Iterator[Array[Byte]] { // Initialize the iterator to the first position rocksIterator.seekToFirst()