-
Notifications
You must be signed in to change notification settings - Fork 213
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
Missing database migration for active_slot_coeff
#1251
Comments
Hi @KtorZ What value should the migration provide, and how should it obtain this value? The current values seem to be obtained by reading Is this parameter available at the point where we perform a DB migration, and should we use the current value, or a historical value instead? (Inspecting the DB manually shows this value is currently |
I tried to reproduce this with the following steps:
I get the following [cardano-wallet:Debug:22] [2020-01-09 03:15:00.49 UTC] Using connection string: /home/jsk/.local/share/cardano-wallet/jormungandr/testnet/wallets/stake-pools.sqlite
[cardano-wallet.query:Debug:22] [2020-01-09 03:15:00.49 UTC] CREATE TEMP TABLE "pool_owner_backup"("pool_id" VARCHAR NOT NULL,"pool_owner" VARCHAR NOT NULL,"pool_owner_index" INTEGER
NOT NULL, PRIMARY KEY ("pool_id","pool_owner","pool_owner_index"))
[cardano-wallet.query:Debug:22] [2020-01-09 03:15:00.49 UTC] INSERT INTO "pool_owner_backup"("pool_id","pool_owner") SELECT "pool_id","pool_owner" FROM "pool_owner"
SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index
[cardano-wallet:Debug:4] [2020-01-09 03:15:00.49 UTC] Logging shutdown.
cardano-wallet-jormungandr: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index I'll try to reproduce with an earlier version ( |
Just tried with [cardano-wallet:Debug:22] [2020-01-09 03:50:23.50 UTC] Using connection string: /home/jsk/.local/share/cardano-wallet/jormungandr/testnet/wallets/stake-pools.sqlite
[cardano-wallet.query:Debug:22] [2020-01-09 03:50:23.51 UTC] CREATE TEMP TABLE "pool_owner_backup"("pool_id" VARCHAR NOT NULL,"pool_owner" VARCHAR NOT NULL,"pool_owner_index" INTEGER NOT NULL, PRIMARY KEY ("pool_id","pool_owner","pool_owner_index"))
[cardano-wallet.query:Debug:22] [2020-01-09 03:50:23.51 UTC] INSERT INTO "pool_owner_backup"("pool_id","pool_owner") SELECT "pool_id","pool_owner" FROM "pool_owner"
SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index
[cardano-wallet:Debug:4] [2020-01-09 03:50:23.51 UTC] Logging shutdown.
cardano-wallet-jormungandr: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index |
Okay. I can finally reproduce the bug described in this issue, but only after performing the following steps:
Then we see: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: checkpoint_backup.active_slot_coeff
[cardano-wallet.worker:Error:28] [2020-01-09 04:13:50.61 UTC] bf04d83b: Worker has exited unexpectedly: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: checkpoint_backup.active_slot_coeff |
@KtorZ Should we create a separate bug report for #1251 (comment)? It's trivial to work around (by deleting |
@jonathanknowles This was a known issue taken care of by #1177. The pool database will "migrate" itself automatically but that's only since v2019.12.23 (or exactly, a few commits after v2019.12.16). |
So, in order to reproduce the bug above, it's probably best to go from v2019.12.13 to v2019.12.23 (or simply current master) such that the pool db migration error is handled, and remains only the active_slot_coeff one. |
@KtorZ Unfortunately this doesn't appear to be working. Going from jsk@neon:~/projects/input-output-hk/cardano-wallet$ stack exec cardano-wallet-jormungandr -- launch --genesis-block lib/jormungandr/test/data/jormungandr/block0.bin
[cardano-wallet:Info:4] [2020-01-13 03:17:06.42 UTC] Using directory: /home/jsk/.local/share/cardano-wallet/jormungandr/testnet
[cardano-wallet:Info:4] [2020-01-13 03:17:06.42 UTC] Using directory: /home/jsk/.local/share/cardano-wallet/jormungandr/testnet/wallets
[cardano-wallet:Info:4] [2020-01-13 03:17:06.42 UTC] Running as v2020.1.7 (git revision: 10b5512222e09ef788dcea82628113add4291460)
[cardano-wallet.application:Info:4] [2020-01-13 03:17:06.42 UTC] Wallet backend server starting...
[cardano-wallet.application:Info:4] [2020-01-13 03:17:06.42 UTC] Node is Jörmungandr on testnet
[cardano-wallet.daedalus-ipc:Info:17] [2020-01-13 03:17:06.42 UTC] Daedalus IPC is not enabled.
[cardano-wallet.network:Notice:18] [2020-01-13 03:17:06.44 UTC] Starting process jormungandr
--genesis-block lib/jormungandr/test/data/jormungandr/block0.bin
--rest-listen 127.0.0.1:35759
--storage /home/jsk/.local/share/cardano-wallet/jormungandr/testnet/chain
[cardano-wallet.network:Info:18] [2020-01-13 03:17:06.44 UTC] [jormungandr.17209] Process started
Jan 13 03:17:06.451 INFO Starting jormungandr 0.8.5 (, release, linux [x86_64]) - [rustc 1.38.0 (625451e37 2019-09-23)], task: init
Jan 13 03:17:06.451 WARN Node started without path to the stored secret keys (not a stake pool or a BFT leader), task: init
Jan 13 03:17:06.452 INFO storing blockchain in '"/home/jsk/.local/share/cardano-wallet/jormungandr/testnet/chain/blocks.sqlite"', task: init
Jan 13 03:17:06.493 WARN No trusted peers joinable to bootstrap the network, task: bootstrap
[cardano-wallet.network:Info:22] [2020-01-13 03:17:07.45 UTC] Waiting for Jörmungandr to be ready on tcp/35759
[cardano-wallet.network:Info:22] [2020-01-13 03:17:07.45 UTC] Jörmungandr is ready.
cardano-wallet-jormungandr: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index
But as pointed out in #1251 (comment), I can work around this issue by deleting wallet.application:Info:22] [2020-01-13 03:20:19.70 UTC] Found existing wallet: b15b1cc1109485096c779c3605a7e22e71654fb9
[cardano-wallet.wallet-engine:Info:28] [2020-01-13 03:20:19.70 UTC] b15b1cc1: Worker has exited unexpectedly: SQLite3 returned ErrorConstraint while attempting to perform step: NOT N
ULL constraint failed: checkpoint_backup.active_slot_coeff |
@jonathanknowles indeed :o ! |
I'm afraid there is one more trouble. Don't know why, but sometimes in the end of an epoch cardanoWallet pools worker may just stuck and remove the database with no any actions after. But it recreates this after manually restart. I cant reproduce it by my wish, so didnt open an issue. Prolly its related with something from this thread. |
Hi @KtorZ @rvl and I had a discussion about this issue earlier today. We came up with two potential solutions: Solution 1: Remove the field
Solution 2: Keep the field
@KtorZ From the above options, do you have a strong preference for how we solve this issue? Thanks! |
1261: widen 'isMigrationError' to catch constraint errors r=KtorZ a=KtorZ # Issue Number <!-- Put here a reference to the issue this PR relates to and which requirements it tackles --> #1251 # Overview <!-- Detail in a few bullet points the work accomplished in this PR --> On start-up, we run persistent migrations and in case of migration issues, we execute some particular handling (e.g. the pool db resets itself). Yet, we failed at catching migration issues coming from constraints introduced later and that can't be satisfied on already existing data. This commit fixes it. Before ====== ``` [cardano-wallet.network:Info:22] Jörmungandr is ready. cardano-wallet-jormungandr: SQLite3 returned ErrorConstraint while attempting to perform step: NOT NULL constraint failed: pool_owner_backup.pool_owner_index (exiting with an error code) ``` After ===== ``` [cardano-wallet.network:Info:22] Jörmungandr is ready. [cardano-wallet.stake-pool-db:Error:22] Failed to migrate the database: : NOT NULL constraint failed: pool_owner_backup.pool_owner_index [cardano-wallet.stake-pool-db:Notice:22] Non backward compatible database found. Removing old database and re-creating it from scratch. Ignore the previous error. [cardano-wallet.stake-pool-db:Notice:22] 1 migrations were applied to the database. (... and continuing as normal) ``` # Comments <!-- Additional comments or screenshots to attach if any --> <!-- Don't forget to: ✓ Self-review your changes to make sure nothing unexpected slipped through ✓ Assign yourself to the PR ✓ Assign one or several reviewer(s) ✓ Once created, link this PR to its corresponding ticket ✓ Assign the PR to a corresponding milestone ✓ Acknowledge any changes required to the Wiki --> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
@Fell-x27 if you'd like to open an issue describing what you saw (logs are especially useful in that case), please do 🙏 @jonathanknowles Solution 1 is not going to be an option I am afraid. The Solution 2 works better if I understand correctly what the approach would be. Incidentally, I just discussed with Daedalus something suggested by a user earlier in a GH ticket: the ability to force-resync a wallet. This would be pretty handy at this level here, forcing to drop every checkpoints in the database (but the genesis one) and, resync. |
1266: Add a manual DB migration step for `active_slot_coeff`. r=KtorZ a=jonathanknowles # Issue Number #1251 # Overview This PR: - [x] Adds the ability to perform manual DB migration actions after connecting to a SQLite database. - [x] Uses this ability to detect whether or not the `active_slot_coeff` field is present in the `checkpoint` table. - [x] Adds the `active_slot_coeff` field manually, if it was not present already, using a default value that is passed down from the network layer. - [ ] Figure out the cause of repeated log entries of the form: ```hs [cardano-wallet.wallet-engine:Info:29] [2020-01-16 09:05:14.78 UTC] e834cdb3: Try rolling back to 0.0 [cardano-wallet.wallet-engine:Info:29] [2020-01-16 09:05:14.78 UTC] e834cdb3: Rolled back to 0.0 ``` # Comments Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
1266: Add a manual DB migration step for `active_slot_coeff`. r=KtorZ a=jonathanknowles # Issue Number #1251 # Overview This PR: - [x] Adds the ability to perform manual DB migration actions after connecting to a SQLite database. - [x] Uses this ability to detect whether or not the `active_slot_coeff` field is present in the `checkpoint` table. - [x] Adds the `active_slot_coeff` field manually, if it was not present already, using a default value that is passed down from the network layer. - [ ] Figure out the cause of repeated log entries of the form: ```hs [cardano-wallet.wallet-engine:Info:29] [2020-01-16 09:05:14.78 UTC] e834cdb3: Try rolling back to 0.0 [cardano-wallet.wallet-engine:Info:29] [2020-01-16 09:05:14.78 UTC] e834cdb3: Rolled back to 0.0 ``` # Comments Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io> Co-authored-by: KtorZ <matthias.benkort@gmail.com>
OK. migration from
|
Automated migration tests are passing -> https://buildkite.com/input-output-hk/cardano-wallet-nightly/builds/371#e64aa5e1-faf7-4ae5-be57-eade6c91f32d |
Context
We "recently" added the
active_slot_coeff
blockchain parameters to the checkpoint data. Yet, for database existing before the release, we have missed a migration..Steps to Reproduce
Expected behavior
Actual behavior
Resolution
active_slot_coeff
. #1266QA
How to reproduce the above:
master
On subsequent runs, nothing is logged, unless the severity is at least
DEBUG
The text was updated successfully, but these errors were encountered: