File tree Expand file tree Collapse file tree
cardano-db-sync/src/Cardano/DbSync/Ledger Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ import Ouroboros.Network.Block (HeaderHash, pointSlot)
118118import System.FS.API (SomeHasFS (.. ), mkFsPath )
119119import System.FS.API.Types (MountPoint (.. ))
120120import System.FS.IO (ioHasFS )
121- import System.FilePath (splitDirectories , (</>) )
121+ import System.FilePath ((</>) )
122122import System.Mem (performMajorGC )
123123import System.Random (genWord64 , newStdGen )
124124
@@ -227,7 +227,13 @@ mkHasLedgerEnv trce protoInfo dir nw maxLovelaceSupply systemStart syncOptions b
227227 LedgerBackendLSM mPath -> do
228228 let lsmPath = fromMaybe (unLedgerStateDir dir </> " lsm" ) mPath
229229 salt <- fst . genWord64 <$> newStdGen
230- let args = LSM. LSMArgs (mkFsPath $ splitDirectories lsmPath) salt (LSM. stdMkBlockIOFS lsmPath)
230+ -- The HasBlockIO is rooted at lsmPath, so the session's FsPath inside it
231+ -- must be the empty path. Passing the full lsmPath here causes the LSM
232+ -- session to be created at <lsmPath>/<lsmPath>, which breaks snapshot
233+ -- bundling in scripts/postgresql-setup.sh (it falls back to the InMemory
234+ -- branch and ships an incomplete tarball; on restore db-sync then can't
235+ -- find the snapshot and replays from genesis).
236+ let args = LSM. LSMArgs (mkFsPath [] ) salt (LSM. stdMkBlockIOFS lsmPath)
231237 res <-
232238 runWithTempRegistry $
233239 (,() )
Original file line number Diff line number Diff line change @@ -176,6 +176,15 @@ function create_snapshot {
176176 # The active/ directory is not needed — it gets cleared on session restore.
177177 tar czf " ${tmp_dir} /${ledger_dir_name} .tar.gz" \
178178 -C " ${state_dir} " " ${ledger_dir_name} " " lsm/snapshots/${ledger_dir_name} " " lsm/metadata"
179+ elif [ -d " ${state_dir} /lsm" ]; then
180+ # State directory contains an lsm/ subtree but the expected snapshot path is missing.
181+ # Refuse to silently fall back to the InMemory branch — the resulting tarball would
182+ # exclude the LSM tree files and restoration would replay from genesis.
183+ echo " ERROR: ${state_dir} /lsm exists but no LSM snapshot found at ${lsm_snap_dir} ." >&2
184+ echo " The LSM session may be using a non-standard layout. Aborting to avoid" >&2
185+ echo " producing an incomplete snapshot." >&2
186+ rm " ${recursive} " " ${force} " " ${tmp_dir} "
187+ exit 1
179188 else
180189 echo " Detected InMemory backend snapshot at slot ${ledger_dir_name} "
181190 # InMemory backend: just the ledger snapshot directory
You can’t perform that action at this time.
0 commit comments