Skip to content

Commit cb61094

Browse files
authored
Merge pull request #1954 from IntersectMBO/kderme/prepare-13.6.0.5
Prepare 13.6.0.5
2 parents ce2fbc3 + 8692f30 commit cb61094

14 files changed

+35
-73
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Revision history for cardano-db-sync
22

3+
## 13.6.0.5
4+
- Fix offchain data so it supports files up to 3MB [#1928]
5+
- Upgrade to PostgreSQL 17
6+
- Stop creating views and deleting them on every restart [#1950]
7+
- Maintain less snapshots
8+
- No longer crash if stage 1 or 2 migration have been altered
9+
- Improvements for Address variant
10+
311
## 13.6.0.4
412
- Fixes an issue from ledger where DRep delegations could be removed under some conditions
513
- Fix an issue with migration from 13.5.x when consumed_tx_out config is enabled

cardano-chain-gen/cardano-chain-gen.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-chain-gen
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: A fake chain generator for testing cardano DB sync.
66
description: A fake chain generator for testing cardano DB sync.
77
homepage: https://github.com/IntersectMBO/cardano-db-sync

cardano-db-sync/cardano-db-sync.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-db-sync
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: The Cardano DB Sync node
66
description: A Cardano node that follows the Cardano chain and inserts data from the
77
chain into a PostgresQL database.

cardano-db-sync/src/Cardano/DbSync.hs

+1-4
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,7 @@ runDbSync metricsSetters knownMigrations iomgr trce params syncNodeConfigFromFil
8888
whenJust mErrors $ \(unknown, stage4orNewStage3) ->
8989
if stage4orNewStage3
9090
then logWarning trce $ Db.renderMigrationValidateError unknown
91-
else do
92-
let msg = Db.renderMigrationValidateError unknown
93-
logError trce msg
94-
throwIO unknown
91+
else logError trce $ Db.renderMigrationValidateError unknown
9592

9693
logInfo trce "Schema migration files validated"
9794

cardano-db-sync/src/Cardano/DbSync/Ledger/State.hs

+5-5
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ storeSnapshotAndCleanupMaybe env oldState appResult blkNo isCons syncState =
333333
Just newEpoch
334334
| newEpochNo <- unEpochNo (Generic.neEpoch newEpoch)
335335
, newEpochNo > 0
336-
, isCons || (newEpochNo `mod` 10 == 0) || newEpochNo >= 503 ->
336+
, isCons || (newEpochNo `mod` 10 == 0) || newEpochNo >= 530 ->
337337
do
338338
-- TODO: Instead of newEpochNo - 1, is there any way to get the epochNo from 'lssOldState'?
339339
liftIO $ saveCleanupState env oldState (Just $ EpochNo $ newEpochNo - 1)
@@ -480,10 +480,10 @@ cleanupLedgerStateFiles env slotNo = do
480480
let (epochBoundary, valid, invalid) = foldr groupFiles ([], [], []) files
481481
-- Remove invalid (ie SlotNo >= current) ledger state files (occurs on rollback).
482482
deleteAndLogFiles env "invalid" invalid
483-
-- Remove all but 6 most recent state files.
484-
deleteAndLogStateFile env "old" (List.drop 3 valid)
485-
-- Remove all but 6 most recent epoch boundary state files.
486-
deleteAndLogStateFile env "old epoch boundary" (List.drop 6 epochBoundary)
483+
-- Remove all but 2 most recent state files.
484+
deleteAndLogStateFile env "old" (List.drop 2 valid)
485+
-- Remove all but 3 most recent epoch boundary state files.
486+
deleteAndLogStateFile env "old epoch boundary" (List.drop 3 epochBoundary)
487487
where
488488
groupFiles ::
489489
LedgerStateFile ->

cardano-db-sync/src/Cardano/DbSync/OffChain/Http.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ httpGetOffChainVoteDataSingle ::
105105
httpGetOffChainVoteDataSingle vurl metaHash anchorType = do
106106
manager <- liftIO $ Http.newManager tlsManagerSettings
107107
request <- parseOffChainUrl url
108-
let req = httpGetBytes manager request 300000 300000 url
108+
let req = httpGetBytes manager request 3000000 3000000 url
109109
httpRes <- handleExceptT (convertHttpException url) req
110110
(respBS, respLBS, mContentType) <- hoistEither httpRes
111111
(ocvd, decodedValue, metadataHash, mWarning) <- parseAndValidateVoteData respBS respLBS metaHash anchorType (Just $ OffChainVoteUrl vurl)

cardano-db-tool/cardano-db-tool.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-db-tool
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: Utilities to manage the cardano-db-sync databases.
66
description: Utilities and executable, used to manage and validate the
77
PostgreSQL db and the ledger database of the cardano-db-sync node

cardano-db/cardano-db.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-db
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: A base PostgreSQL component for the cardano-db-sync node.
66
description: Code for the Cardano DB Sync node that is shared between the
77
cardano-db-node and other components.

cardano-db/test/cardano-db-test.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-db-test
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: Tests for the base functionality of the cardano-db library
66
description: Code for the Cardano DB Sync node that is shared between the
77
cardano-db-node and other components.

cardano-smash-server/cardano-smash-server.cabal

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.6
22

33
name: cardano-smash-server
4-
version: 13.6.0.4
4+
version: 13.6.0.5
55
synopsis: The Cardano smash server
66
description: Please see the README on GitHub at
77
<https://github.com/IntersectMBO/cardano-db-sync/cardano-smash-server/#readme>

docker-compose.example.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ services:
5959
max-file: "10"
6060

6161
cardano-db-sync:
62-
image: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.4
62+
image: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.5
6363
environment:
6464
- NETWORK=${NETWORK:-mainnet}
6565
- POSTGRES_HOST=postgres

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ services:
5454
max-file: "10"
5555

5656
cardano-db-sync:
57-
image: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.4
57+
image: ghcr.io/intersectmbo/cardano-db-sync:13.6.0.5
5858
environment:
5959
- DB_SYNC_CONFIG=${DB_SYNC_CONFIG:-}
6060
- DISABLE_LEDGER=${DISABLE_LEDGER}

schema/migration-1-0002-20190912.sql

+12-27
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,19 @@
1-
-- Drop all VIEWs linked to the 'cexplorer' table.
21

3-
-- Many schema migration changes will fail if they operate on a table that is part of a VIEW.
4-
-- So we drop all VIEWs here and recreate them later.
5-
6-
CREATE FUNCTION drop_cexplorer_views () RETURNS void language plpgsql as $$
7-
8-
DECLARE vname text;
9-
DECLARE next_version int;
102

3+
CREATE FUNCTION migrate() RETURNS void AS $$
4+
DECLARE
5+
next_version int ;
116
BEGIN
12-
SELECT stage_one + 1 INTO next_version FROM "schema_version";
7+
SELECT stage_one + 1 INTO next_version FROM "schema_version" ;
138
IF next_version = 2 THEN
14-
-- Only update the schema version if the versions are as expected.
15-
UPDATE "schema_version" SET stage_one = next_version;
16-
RAISE NOTICE 'DB has been migrated to stage_one version %', next_version;
17-
END IF;
9+
-- Empty migration file just to raise the version
1810

19-
-- Always run the following.
20-
for vname in
21-
select '"' || table_name || '"'
22-
from information_schema.views
23-
where table_catalog = current_database ()
24-
and table_schema = 'public'
25-
and table_name !~* 'pg_stat_.*'
26-
loop
27-
execute format ('drop view if exists %s cascade ;', vname) ;
28-
raise notice 'Dropping view : %', vname ;
29-
end loop ;
30-
end $$ ;
11+
UPDATE schema_version SET stage_one = next_version ;
12+
RAISE NOTICE 'DB has been migrated to stage_one version %', next_version ;
13+
END IF ;
14+
END ;
15+
$$ LANGUAGE plpgsql ;
3116

32-
SELECT drop_cexplorer_views () ;
17+
SELECT migrate() ;
3318

34-
DROP FUNCTION drop_cexplorer_views () ;
19+
DROP FUNCTION migrate() ;

schema/migration-3-0001-20190816.sql

-28
Original file line numberDiff line numberDiff line change
@@ -1,28 +0,0 @@
1-
-- Create all the views.
2-
3-
-- The views are always created because all views are deleted at the start ot the
4-
-- migration process.
5-
6-
-- Conventions:
7-
-- * Views use `_view` as a suffix to show they are views rather than table.
8-
9-
-- A utxo view which shows all unspent transaction outputs including the un-redeemed redeem
10-
-- addresses.
11-
create or replace view utxo_byron_view as select
12-
tx_out.*
13-
from tx_out left outer join tx_in
14-
on tx_out.tx_id = tx_in.tx_out_id and tx_out.index = tx_in.tx_out_index
15-
where tx_in.tx_in_id is null ;
16-
17-
18-
-- A utxo view which shows all unspent transaction outputs *excluding* the un-redeemed redeem
19-
-- addresses.
20-
-- This should produce the same query results as the above `utxo_byron_view` for Shelley addresses
21-
-- and non-redeem Byron addresses.
22-
create or replace view utxo_view as select
23-
tx_out.*
24-
from tx_out
25-
left outer join tx_in on tx_out.tx_id = tx_in.tx_out_id and tx_out.index = tx_in.tx_out_index
26-
left outer join tx on tx.id = tx_out.tx_id
27-
left outer join block on tx.block_id = block.id
28-
where tx_in.tx_in_id is null and block.epoch_no is not null ;

0 commit comments

Comments
 (0)