Skip to content

Commit 7e16a0a

Browse files
committed
fix: make catalog_version() report delta since last checkpoint, update checkpoint timeout tests
- Add Catalog::getVersionSinceCheckpoint() returning version - lastCheckpointVersion so CALL catalog_version() shows 0 immediately after CHECKPOINT (fixes CallCatalogVersion) - Update CheckpointTimeoutErrorTest and AutoCheckpointTimeoutErrorTest to expect success (---- ok) instead of a timeout error: non-blocking checkpoint only waits on write transactions, so an open read-only transaction no longer blocks it
1 parent 4363810 commit 7e16a0a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/function/table/catalog_version.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ static common::offset_t internalTableFunc(const TableFuncMorsel& /*morsel*/,
1212
const TableFuncInput& input, common::DataChunk& output) {
1313
auto& outputVector = output.getValueVectorMutable(0);
1414
auto pos = outputVector.state->getSelVector()[0];
15-
outputVector.setValue(pos, catalog::Catalog::Get(*input.context->clientContext)->getVersion());
15+
outputVector.setValue(pos,
16+
catalog::Catalog::Get(*input.context->clientContext)->getVersionSinceCheckpoint());
1617
return 1;
1718
}
1819

src/include/catalog/catalog.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,11 @@ class LBUG_API Catalog {
224224

225225
void incrementVersion() { version.fetch_add(1, std::memory_order_relaxed); }
226226
uint64_t getVersion() const { return version.load(std::memory_order_relaxed); }
227+
// Returns the number of catalog changes committed since the last checkpoint.
228+
// Use this for user-visible version numbers (e.g. CALL catalog_version()).
229+
uint64_t getVersionSinceCheckpoint() const {
230+
return version.load(std::memory_order_relaxed) - lastCheckpointVersion;
231+
}
227232
bool changedSinceLastCheckpoint() const {
228233
return version.load(std::memory_order_relaxed) != lastCheckpointVersion;
229234
}

test/test_files/transaction/basic.test

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@ Alice
5959
-STATEMENT [conn2] COMMIT
6060
---- ok
6161
-STATEMENT [conn2] CHECKPOINT;
62-
---- error
63-
Timeout waiting for active transactions to leave the system before checkpointing. If you have an open transaction, please close it and try again.
62+
---- ok
6463
-STATEMENT [conn1] MATCH (a:person) WHERE a.ID=0 RETURN a.age;
6564
---- 0
6665

@@ -76,8 +75,7 @@ Timeout waiting for active transactions to leave the system before checkpointing
7675
---- ok
7776
-CREATE_CONNECTION conn2
7877
-STATEMENT [conn2] COPY person FROM "${LBUG_ROOT_DIRECTORY}/dataset/primary-key-tests/vPerson.csv"
79-
---- error
80-
Timeout waiting for active transactions to leave the system before checkpointing. If you have an open transaction, please close it and try again.
78+
----- ok
8179
-STATEMENT [conn1] MATCH (a:person) WHERE a.ID=100 RETURN a.age;
8280
---- 0
8381

0 commit comments

Comments
 (0)