Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: drop sqlite #1480

Merged
merged 15 commits into from
Aug 19, 2019
Merged

multi: drop sqlite #1480

merged 15 commits into from
Aug 19, 2019

Conversation

buck54321
Copy link
Member

@buck54321 buck54321 commented Jul 26, 2019

*Database Upgrade* - Create a backup before running this branch

Removes SQLite database. Everything is moved to ChainDB. In fact, nearly everything that needed to be moved was put in pgblockchain.go for now. I'll probably do some more organizing before removing from draft status, though.

For full testing, you'll need dcrlabs/bug-free-happiness#6

It has passed the following tests.

  • go test with all combinations of -tags in dcrpg
  • apiload -a rotation
  • simnet reorg test
  • fresh DB test

The database upgrade itself is fairly long. Took ~30 minutes on my SSD. This is because the entire blockchain must be requested again and the ticket pool evolved appropriately to populate the stats table.

I think that @chappjc has expressed some interest in combining ChainDB and ChainDBRPC. I didn't do that yet, but unless there a reason not to, I may grab that here as well. done

In addition to some further organizing the dcrpg package, I imagine there is some optimization to be done in the main loop now that there are fewer data sources to sync.

db/dcrpg/internal/stats.go Outdated Show resolved Hide resolved
Copy link
Member

@chappjc chappjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial review: it's a thing of beauty. RIP sqlite. Just a handful of minor issues. Will do a deeper dive with testing.

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@@ -579,7 +579,7 @@ type TicketPoolValsAndSizes struct {
StartHeight uint32 `json:"start_height"`
EndHeight uint32 `json:"end_height"`
Value []float64 `json:"value"`
Size []float64 `json:"size"`
Size []uint32 `json:"size"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: api/types major version bump needed (to v5)

db/dcrpg/internal/blockstmts.go Outdated Show resolved Hide resolved
db/dcrpg/internal/stats.go Outdated Show resolved Hide resolved
db/dcrpg/tables.go Show resolved Hide resolved
db/dcrpg/upgrades.go Outdated Show resolved Hide resolved
db/dcrpg/upgrades.go Show resolved Hide resolved
db/dcrpg/upgrades.go Show resolved Hide resolved
go.sum Outdated Show resolved Hide resolved

func makeARRAYOfBIGINTs(ints []uint64) string {
if len(ints) == 0 {
return "'{}'::BIGINT[]" // cockroachdb: "ARRAY[]:::BIGINT[]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I wonder if I was doing this string gen stuff because cockroachdb sucks with the lib/pq driver. Ah well, maybe cockroach will be more compatible someday. The right way to do this is how you got it now, with pq.Array/etc.

@chappjc
Copy link
Member

chappjc commented Aug 16, 2019

Would you also please remove SQLT=debug from sample-dcrdata.conf and dcrdata-simnet.conf?

@chappjc
Copy link
Member

chappjc commented Aug 16, 2019

All good with a fresh resync:

[INF] PSQL: Avg. speed: 1434 tx/s, 5263 vout/s

Although I miss a report at this stage (before indexing etc.) that says height and elapsed time.

@chappjc chappjc added this to the 5.2 milestone Aug 16, 2019
@chappjc
Copy link
Member

chappjc commented Aug 16, 2019

Upgrade went smoothly in 12 minutes:

2019-08-16 13:58:42.522 [INF] PSQL: DB schema version 1.1.0 upgrading to version 1.2.0
2019-08-16 13:58:42.522 [INF] PSQL: Performing database upgrade 1.1.0 -> 1.2.0
2019-08-16 13:58:42.550 [INF] SKDB: Loading ticket pool DB. This may take a minute...
2019-08-16 13:58:42.552 [INF] SKDB: badger: All 0 tables opened in 0s
2019-08-16 13:58:42.553 [DBG] SKDB: badger value log not rewritten (OK).
2019-08-16 13:58:42.553 [INF] SKDB: Loading all ticket pool diffs...
2019-08-16 13:58:42.553 [INF] SKDB: Successfully loaded 0 ticket pool diffs
2019-08-16 13:58:42.557 [INF] SKDB: Creating new stake DB.
2019-08-16 13:58:42.558 [DBG] SKDB: Initialized new stake db.
2019-08-16 13:58:42.558 [INF] SKDB: Advancing ticket pool DB to tip via diffs...
2019-08-16 13:58:42.558 [INF] SKDB: Pre-populating live ticket cache and computing pool value...
2019-08-16 13:58:42.558 [INF] PSQL: Processing blocks 0 - 9999
2019-08-16 13:59:02.566 [INF] PSQL: Processing blocks 10000 - 19999
2019-08-16 13:59:20.509 [INF] PSQL: Processing blocks 20000 - 29999
2019-08-16 13:59:38.938 [INF] PSQL: Processing blocks 30000 - 39999
2019-08-16 13:59:57.470 [INF] PSQL: Processing blocks 40000 - 49999
2019-08-16 14:00:16.433 [INF] PSQL: Processing blocks 50000 - 59999
2019-08-16 14:00:35.677 [INF] PSQL: Processing blocks 60000 - 69999
2019-08-16 14:00:55.103 [INF] PSQL: Processing blocks 70000 - 79999
2019-08-16 14:01:14.514 [INF] PSQL: Processing blocks 80000 - 89999
2019-08-16 14:01:35.288 [INF] PSQL: Processing blocks 90000 - 99999
2019-08-16 14:01:56.180 [INF] PSQL: Processing blocks 100000 - 109999
2019-08-16 14:02:17.116 [INF] PSQL: Processing blocks 110000 - 119999
2019-08-16 14:02:38.238 [INF] PSQL: Processing blocks 120000 - 129999
2019-08-16 14:03:00.541 [INF] PSQL: Processing blocks 130000 - 139999
2019-08-16 14:03:23.167 [INF] PSQL: Processing blocks 140000 - 149999
2019-08-16 14:03:45.578 [INF] PSQL: Processing blocks 150000 - 159999
2019-08-16 14:04:10.042 [INF] PSQL: Processing blocks 160000 - 169999
2019-08-16 14:04:32.820 [INF] PSQL: Processing blocks 170000 - 179999
2019-08-16 14:04:55.176 [INF] PSQL: Processing blocks 180000 - 189999
2019-08-16 14:05:17.803 [INF] PSQL: Processing blocks 190000 - 199999
2019-08-16 14:05:41.413 [INF] PSQL: Processing blocks 200000 - 209999
2019-08-16 14:06:05.344 [INF] PSQL: Processing blocks 210000 - 219999
2019-08-16 14:06:27.689 [INF] PSQL: Processing blocks 220000 - 229999
2019-08-16 14:06:48.997 [INF] PSQL: Processing blocks 230000 - 239999
2019-08-16 14:07:11.072 [INF] PSQL: Processing blocks 240000 - 249999
2019-08-16 14:07:33.432 [INF] PSQL: Processing blocks 250000 - 259999
2019-08-16 14:07:56.180 [INF] PSQL: Processing blocks 260000 - 269999
2019-08-16 14:08:17.460 [INF] PSQL: Processing blocks 270000 - 279999
2019-08-16 14:08:39.116 [INF] PSQL: Processing blocks 280000 - 289999
2019-08-16 14:09:00.639 [INF] PSQL: Processing blocks 290000 - 299999
2019-08-16 14:09:22.046 [INF] PSQL: Processing blocks 300000 - 309999
2019-08-16 14:09:43.151 [INF] PSQL: Processing blocks 310000 - 319999
2019-08-16 14:10:04.623 [INF] PSQL: Processing blocks 320000 - 329999
2019-08-16 14:10:25.520 [INF] PSQL: Processing blocks 330000 - 339999
2019-08-16 14:10:46.418 [INF] PSQL: Processing blocks 340000 - 349999
2019-08-16 14:11:07.269 [INF] PSQL: Processing blocks 350000 - 359999
2019-08-16 14:11:24.718 [DBG] PSQL: meta height 356568 / blocks height 356568

db/dcrpg/sync.go Outdated
panic("invalid starting height")
}

log.Info("Current best block (chain server): ", lastBlock)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is not (chain server), but the postgresql db height, whatever we want to call that.
But also logging nodeHeight around here would be good too.

@chappjc chappjc merged commit 1442c53 into decred:master Aug 19, 2019
@chappjc chappjc mentioned this pull request Oct 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants