Skip to content

Commit 0366cf4

Browse files
committed
leave closing iterators to GC again
1 parent ac514f3 commit 0366cf4

File tree

4 files changed

+4
-16
lines changed

4 files changed

+4
-16
lines changed

build.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ libraryDependencies ++= Seq(
2525
"io.grpc" % "grpc-netty" % scalapb.compiler.Version.grpcJavaVersion,
2626
"io.grpc" % "grpc-services" % scalapb.compiler.Version.grpcJavaVersion,
2727
"com.thesamet.scalapb" %% "scalapb-runtime-grpc" % scalapb.compiler.Version.scalapbVersion,
28-
"org.rocksdb" % "rocksdbjni" % "7.9.2",
28+
"org.rocksdb" % "rocksdbjni" % "5.11.3",
2929
"com.github.scopt" %% "scopt" % "3.7.0"
3030
)
3131

src/main/scala/com/scalableminds/fossildb/db/RocksDBStore.scala

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
5656
Files.createDirectories(backupDir)
5757

5858
RocksDB.loadLibrary()
59-
val backupEngine = BackupEngine.open(Env.getDefault, new BackupEngineOptions(backupDir.toString))
59+
val backupEngine = BackupEngine.open(Env.getDefault, new BackupableDBOptions(backupDir.toString))
6060
backupEngine.createNewBackup(db)
6161
backupEngine.purgeOldBackups(1)
6262
backupEngine.getBackupInfo.asScala.headOption.map(info => BackupInfo(info.backupId, info.timestamp, info.size))
@@ -66,7 +66,7 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
6666
logger.info("Restoring from backup. RocksDB temporarily unavailable")
6767
close()
6868
RocksDB.loadLibrary()
69-
val backupEngine = BackupEngine.open(Env.getDefault, new BackupEngineOptions(backupDir.toString))
69+
val backupEngine = BackupEngine.open(Env.getDefault, new BackupableDBOptions(backupDir.toString))
7070
backupEngine.restoreDbFromLatestBackup(dataDir.toString, dataDir.toString, new RestoreOptions(true))
7171
logger.info("Restoring from backup complete. Reopening RocksDB")
7272
}
@@ -85,7 +85,6 @@ class RocksDBManager(dataDir: Path, columnFamilies: List[String], optionsFilePat
8585
newManager.columnFamilyHandles.foreach { case (name, handle) =>
8686
val dataIterator = getStoreForColumnFamily(name).get.scan("", None)
8787
dataIterator.foreach(el => newManager.db.put(handle, el.key.getBytes, el.value))
88-
dataIterator.close()
8988
}
9089
logger.info("Writing data completed. Start compaction")
9190
newManager.db.compactRange()
@@ -112,8 +111,6 @@ class RocksDBKeyIterator(it: RocksIterator, prefix: Option[String]) extends Iter
112111
new String(it.key().map(_.toChar))
113112
}
114113

115-
def close(): Unit = it.close()
116-
117114
}
118115

119116
class RocksDBIterator(it: RocksIterator, prefix: Option[String]) extends Iterator[KeyValuePair[Array[Byte]]] {
@@ -126,8 +123,6 @@ class RocksDBIterator(it: RocksIterator, prefix: Option[String]) extends Iterato
126123
value
127124
}
128125

129-
def close(): Unit = it.close()
130-
131126
}
132127

133128
class RocksDBStore(db: RocksDB, handle: ColumnFamilyHandle) extends LazyLogging {

src/main/scala/com/scalableminds/fossildb/db/VersionedKeyValueStore.scala

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class VersionFilterIterator(it: RocksDBIterator, version: Option[Long]) extends
5252
value
5353
}
5454

55-
def close(): Unit = it.close()
56-
5755
}
5856

5957
class KeyOnlyIterator[T](underlying: RocksDBStore, startAfterKey: Option[String]) extends Iterator[String] {
@@ -116,12 +114,9 @@ class VersionedKeyValueStore(underlying: RocksDBStore) {
116114
private def scanVersionValuePairs(key: String, version: Option[Long] = None): Iterator[VersionedKeyValuePair[Array[Byte]]] = {
117115
requireValidKey(key)
118116
val prefix = s"$key@"
119-
val it = underlying.scan(version.map(VersionedKey(key, _).toString).getOrElse(prefix), Some(prefix))
120-
val res = it.flatMap { pair =>
117+
underlying.scan(version.map(VersionedKey(key, _).toString).getOrElse(prefix), Some(prefix)).flatMap { pair =>
121118
VersionedKey(pair.key).map(VersionedKeyValuePair(_, pair.value))
122119
}
123-
it.close()
124-
res
125120
}
126121

127122
private def scanVersionsOnly(key: String, version: Option[Long] = None): Iterator[VersionedKey] = {
@@ -137,7 +132,6 @@ class VersionedKeyValueStore(underlying: RocksDBStore) {
137132
prefix.foreach{ p => requireValidKey(p)}
138133
val iterator: VersionFilterIterator = scanKeys(key, prefix, version)
139134
val asSequence = iterator.take(limit.getOrElse(Int.MaxValue)).toSeq
140-
iterator.close()
141135
val keys = asSequence.map(_.key)
142136
val values = asSequence.map(_.value)
143137
val versions = asSequence.map(_.version)

src/test/scala/com/scalableminds/fossildb/FossilDBSuite.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class FossilDBSuite extends FlatSpec with BeforeAndAfterEach with TestHelpers wi
2424
private val healthClient = HealthGrpc.newBlockingStub(channel)
2525
private val collectionA = "collectionA"
2626
private val collectionB = "collectionB"
27-
private val collectionC = "collectionC"
2827

2928
private val testData1 = ByteString.copyFromUtf8("testData1")
3029
private val testData2 = ByteString.copyFromUtf8("testData2")

0 commit comments

Comments
 (0)