From 60035018310fb603147cc7d4578a97c8f0a3ffdf Mon Sep 17 00:00:00 2001 From: Christophe Diederichs Date: Wed, 12 Jun 2024 22:49:13 +0100 Subject: [PATCH] only reset writers on reindex instead of closing --- index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index f79a5dad..8d657e21 100644 --- a/index.js +++ b/index.js @@ -1009,9 +1009,11 @@ module.exports = class Autobase extends ReadyResource { await this.system.update() } + const active = [] + for (const w of this.activeWriters) active.push(w.core.key) + const sameIndexers = this.system.sameIndexers(this.linearizer.indexers) - await this._closeAllActiveWriters(true) await this._makeLinearizer(this.system) if (!sameIndexers) await this._viewStore.migrate() @@ -1019,10 +1021,11 @@ module.exports = class Autobase extends ReadyResource { this.queueFastForward() - if (this.localWriter) { - const value = await this.system.get(this.local.key) + for (const w of this.activeWriters) { + const value = await this.system.get(w.core.key) const length = value ? value.length : 0 - this.localWriter.reset(length) + w.reset(length) + this._resumeWriter(w) } if (!this.localWriter || !this.localWriter.isIndexer) return