From d151a2685a1a40538df1ed97317d6f859466c76b Mon Sep 17 00:00:00 2001 From: Norbert Hartl Date: Wed, 2 Oct 2024 23:44:56 +0200 Subject: [PATCH] fixed creation of journal file and skip bogus recover --- src/Soil-Core/SoilDatabaseRecovery.class.st | 11 ++++++++++- src/Soil-Core/SoilLogSequenceNumber.class.st | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Soil-Core/SoilDatabaseRecovery.class.st b/src/Soil-Core/SoilDatabaseRecovery.class.st index 2cc7be78..46450bc3 100644 --- a/src/Soil-Core/SoilDatabaseRecovery.class.st +++ b/src/Soil-Core/SoilDatabaseRecovery.class.st @@ -99,7 +99,16 @@ SoilDatabaseRecovery >> recover [ fragmentFile := journal openFragmentForLSN: lastCheckpoint. "The log sequence number of a successful checkpoint points to the checkpoint entry that was last written" - checkpointEntry := SoilJournalEntry readFrom: fragmentFile stream. + checkpointEntry := [ SoilJournalEntry readFrom: fragmentFile stream ] + on: Error + do: [ :error | + "in case of a bogus checkpoint position we cannot recover the file but + create a new one and continue" + journal + currentFragmentFile: fragmentFile; + cycleFragmentFile. + soil checkpoint. + ^ self ]. "If the last checkpoint was successful we are at the end of the file and can return because the database is in a sane state" fragmentFile atEnd ifTrue: [ ^ self ]. diff --git a/src/Soil-Core/SoilLogSequenceNumber.class.st b/src/Soil-Core/SoilLogSequenceNumber.class.st index 7f9e8cfe..1b3abb46 100644 --- a/src/Soil-Core/SoilLogSequenceNumber.class.st +++ b/src/Soil-Core/SoilLogSequenceNumber.class.st @@ -67,7 +67,7 @@ SoilLogSequenceNumber >> hexOffset [ { #category : #testing } SoilLogSequenceNumber >> isInitial [ - ^ value = 0 + ^ self fileOffset = 0 ] { #category : #printing }