From 7e55544eefd55b5fc3a80176cbdb0420019160e0 Mon Sep 17 00:00:00 2001 From: Marco Neumann Date: Thu, 20 May 2021 10:32:40 +0200 Subject: [PATCH] fix: correctly track chunk ID counter during catalog replay --- server/src/db.rs | 3 +++ server/src/db/catalog/partition.rs | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/server/src/db.rs b/server/src/db.rs index 00b88b27b8..e2093a0609 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -2917,5 +2917,8 @@ mod tests { let chunk = chunk.read(); assert!(matches!(chunk.state(), ChunkState::ObjectStoreOnly(_))); } + + // ==================== check: DB still writable ==================== + write_lp(db.as_ref(), "cpu bar=1 10"); } } diff --git a/server/src/db/catalog/partition.rs b/server/src/db/catalog/partition.rs index c813afbbf5..9e91169637 100644 --- a/server/src/db/catalog/partition.rs +++ b/server/src/db/catalog/partition.rs @@ -124,6 +124,9 @@ impl Partition { /// Create new chunk that is only in object store (= parquet file). /// + /// The table-specific chunk ID counter will be set to + /// `max(current, chunk_id + 1)`. + /// /// Fails if the chunk already exists. pub fn create_object_store_only_chunk( &mut self, @@ -153,7 +156,12 @@ impl Partition { table_name, chunk_id, }), - None => Ok(chunk), + None => { + // bump chunk ID counter + table.next_chunk_id = table.next_chunk_id.max(chunk_id + 1); + + Ok(chunk) + } } }