Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ import Ouroboros.Network.Block (HeaderHash, pointSlot)
import System.FS.API (SomeHasFS (..), mkFsPath)
import System.FS.API.Types (MountPoint (..))
import System.FS.IO (ioHasFS)
import System.FilePath (splitDirectories, (</>))
import System.FilePath ((</>))
import System.Mem (performMajorGC)
import System.Random (genWord64, newStdGen)

Expand Down Expand Up @@ -227,7 +227,13 @@ mkHasLedgerEnv trce protoInfo dir nw maxLovelaceSupply systemStart syncOptions b
LedgerBackendLSM mPath -> do
let lsmPath = fromMaybe (unLedgerStateDir dir </> "lsm") mPath
salt <- fst . genWord64 <$> newStdGen
let args = LSM.LSMArgs (mkFsPath $ splitDirectories lsmPath) salt (LSM.stdMkBlockIOFS lsmPath)
-- The HasBlockIO is rooted at lsmPath, so the session's FsPath inside it
-- must be the empty path. Passing the full lsmPath here causes the LSM
-- session to be created at <lsmPath>/<lsmPath>, which breaks snapshot
-- bundling in scripts/postgresql-setup.sh (it falls back to the InMemory
-- branch and ships an incomplete tarball; on restore db-sync then can't
-- find the snapshot and replays from genesis).
let args = LSM.LSMArgs (mkFsPath []) salt (LSM.stdMkBlockIOFS lsmPath)
res <-
runWithTempRegistry $
(,())
Expand Down
9 changes: 9 additions & 0 deletions scripts/postgresql-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,15 @@ function create_snapshot {
# The active/ directory is not needed — it gets cleared on session restore.
tar czf "${tmp_dir}/${ledger_dir_name}.tar.gz" \
-C "${state_dir}" "${ledger_dir_name}" "lsm/snapshots/${ledger_dir_name}" "lsm/metadata"
elif [ -d "${state_dir}/lsm" ]; then
# State directory contains an lsm/ subtree but the expected snapshot path is missing.
# Refuse to silently fall back to the InMemory branch — the resulting tarball would
# exclude the LSM tree files and restoration would replay from genesis.
echo "ERROR: ${state_dir}/lsm exists but no LSM snapshot found at ${lsm_snap_dir}." >&2
echo " The LSM session may be using a non-standard layout. Aborting to avoid" >&2
echo " producing an incomplete snapshot." >&2
rm "${recursive}" "${force}" "${tmp_dir}"
exit 1
else
echo "Detected InMemory backend snapshot at slot ${ledger_dir_name}"
# InMemory backend: just the ledger snapshot directory
Expand Down
Loading