This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 631
[CBR-495] Fix inconsistent metadata store after deletion #3943
Merged
iohk-bors
merged 2 commits into
release/2.0.0
from
KtorZ/CBR-495/fix-inconsistent-metadata-store-after-deletion
Dec 11, 2018
Merged
[CBR-495] Fix inconsistent metadata store after deletion #3943
iohk-bors
merged 2 commits into
release/2.0.0
from
KtorZ/CBR-495/fix-inconsistent-metadata-store-after-deletion
Dec 11, 2018
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This fix is actually two folds: - It discards incoherent transactions fetched from the DB, if any, and shout a warning in the log. This is in order to make the system more resilient to conconcurrent calls while a wallet or account is being deleted (since metadata and accounts / wallets are stored in separated databases, we can't easily run both delete in a single transaction). - It also deletes corresponding metadata when an account or a wallet is removed. This may cause extra damage? What if there are pending transactions when we delete the account or wallet.
KtorZ
changed the title
Ktor z/cbr 495/fix inconsistent metadata store after deletion
[CBR-495] Fix inconsistent metadata store after deletion
Dec 8, 2018
kderme
suggested changes
Dec 9, 2018
kderme
reviewed
Dec 9, 2018
…with no Txs-Accounts relations in SQlite
Added an extra integration test to illustrate last comment and @kderme addition. scenario "Reg#141: metadata becomes inconsistent after a wallet is deleted and restored" $ do
fixture <- setup $ defaultSetup
& initialCoins .~ [500000]
[verifyTxInHistory, verifyWalletIsRestored] <- sequence
[ do -- // 1 Make sure there's a transaction in the history
response <- request $ Client.postTransaction $- Payment
(defaultSource fixture)
(defaultDistribution 42 fixture)
defaultGroupingPolicy
noSpendingPassword
verify response
[ expectTxStatusEventually (fixture ^. wallet) [InNewestBlocks, Persisted]
]
-- // 3 Later, check that we can recover that transaction
return $ verify response
[ expectTxInHistoryOf (fixture ^. wallet)
]
, do -- // 2 Remove and then, restore the wallet
request_ $ Client.deleteWallet $- fixture ^. wallet . walletId
response <- request $ Client.postWallet $- NewWallet
(fixture ^. backupPhrase)
noSpendingPassword
defaultAssuranceLevel
defaultWalletName
RestoreWallet
return $ verify response
[ expectWalletEventuallyRestored
]
]
verifyWalletIsRestored >> verifyTxInHistory Succeeds with the last addition, but otherwise fails with:
|
KtorZ
commented
Dec 10, 2018
-- We handle Nothing and (Just True) the same here, since | ||
-- it's possible that there is no Meta with this Inputs/Outputs. | ||
-- In the future we may consider doing a better cleanup to avoid | ||
-- such cases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another integration test added to cover these bits 👍 , cf comments.
kderme
approved these changes
Dec 10, 2018
bors r+ |
iohk-bors bot
added a commit
that referenced
this pull request
Dec 10, 2018
3943: [CBR-495] Fix inconsistent metadata store after deletion r=KtorZ a=KtorZ ## Description We store some information related to transaction in the metadata store (sqlite). However, when looking up transaction with metadata referring to wallet we don't know about, we fail with a not so friendly error "WalletNotFound" despite no wallet being given as part of the query. This fix is actually two folds: - It discards incoherent transactions fetched from the DB, if any, and shout a warning in the log. This is in order to make the system more resilient to conconcurrent calls while a wallet or account is being deleted (since metadata and accounts / wallets are stored in separated databases, we can't easily run both delete in a single transaction). - It also deletes corresponding metadata when an account or a wallet is removed. This may cause extra damage? What if there are pending transactions when we delete the account or wallet. ## Linked issue [CBR-495](https://iohk.myjetbrains.com/youtrack/issue/CBR-495) 3947: [CBR-496] Fix --rebuild-db not rebuilding sqlite r=jmitchell a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> Turns out we aren't actually removing the sqlite database when passing --rebuild-db becaue the SQLite db is actually stored in a file and not a directory. ## Linked issue <!--- Put here the relevant issue from YouTrack --> [[CBR-496]](https://iohk.myjetbrains.com/youtrack/issue/CO-445) Co-authored-by: KtorZ <[email protected]> Co-authored-by: kderme <[email protected]>
Timed out (retrying...) |
iohk-bors bot
added a commit
that referenced
this pull request
Dec 10, 2018
3943: [CBR-495] Fix inconsistent metadata store after deletion r=KtorZ a=KtorZ ## Description We store some information related to transaction in the metadata store (sqlite). However, when looking up transaction with metadata referring to wallet we don't know about, we fail with a not so friendly error "WalletNotFound" despite no wallet being given as part of the query. This fix is actually two folds: - It discards incoherent transactions fetched from the DB, if any, and shout a warning in the log. This is in order to make the system more resilient to conconcurrent calls while a wallet or account is being deleted (since metadata and accounts / wallets are stored in separated databases, we can't easily run both delete in a single transaction). - It also deletes corresponding metadata when an account or a wallet is removed. This may cause extra damage? What if there are pending transactions when we delete the account or wallet. ## Linked issue [CBR-495](https://iohk.myjetbrains.com/youtrack/issue/CBR-495) Co-authored-by: KtorZ <[email protected]> Co-authored-by: kderme <[email protected]>
Timed out |
bors r+ |
iohk-bors bot
added a commit
that referenced
this pull request
Dec 10, 2018
3943: [CBR-495] Fix inconsistent metadata store after deletion r=jmitchell a=KtorZ ## Description We store some information related to transaction in the metadata store (sqlite). However, when looking up transaction with metadata referring to wallet we don't know about, we fail with a not so friendly error "WalletNotFound" despite no wallet being given as part of the query. This fix is actually two folds: - It discards incoherent transactions fetched from the DB, if any, and shout a warning in the log. This is in order to make the system more resilient to conconcurrent calls while a wallet or account is being deleted (since metadata and accounts / wallets are stored in separated databases, we can't easily run both delete in a single transaction). - It also deletes corresponding metadata when an account or a wallet is removed. This may cause extra damage? What if there are pending transactions when we delete the account or wallet. ## Linked issue [CBR-495](https://iohk.myjetbrains.com/youtrack/issue/CBR-495) 3947: [CBR-496] Fix --rebuild-db not rebuilding sqlite r=jmitchell a=KtorZ ## Description <!--- A brief description of this PR and the problem is trying to solve --> Turns out we aren't actually removing the sqlite database when passing --rebuild-db becaue the SQLite db is actually stored in a file and not a directory. ## Linked issue <!--- Put here the relevant issue from YouTrack --> [[CBR-496]](https://iohk.myjetbrains.com/youtrack/issue/CO-445) Co-authored-by: KtorZ <[email protected]> Co-authored-by: kderme <[email protected]>
Build succeeded |
iohk-bors
bot
deleted the
KtorZ/CBR-495/fix-inconsistent-metadata-store-after-deletion
branch
December 11, 2018 00:22
12 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We store some information related to transaction in the metadata store (sqlite). However, when looking up transaction with metadata referring to wallet we don't know about, we fail with a not so friendly error "WalletNotFound" despite no wallet being given as part of the query.
This fix is actually two folds:
It discards incoherent transactions fetched from the DB, if any,
and shout a warning in the log. This is in order to make the system
more resilient to conconcurrent calls while a wallet or account is
being deleted (since metadata and accounts / wallets are stored in
separated databases, we can't easily run both delete in a single
transaction).
It also deletes corresponding metadata when an account or a wallet
is removed. This may cause extra damage? What if there are pending
transactions when we delete the account or wallet.
Linked issue
CBR-495
Type of change
Developer checklist
Testing checklist
QA Steps
On input-output-hk/cardano-sl I've added the following integration tests:
Both now passes. Beside, in case of future inconsistency like this in the DB, the whole endpoint won't fail but instead, inconsistent transactions will be discarded and a warning printed in the logs:
Screenshots (if available)
How to merge
Send the message
bors r+
to merge this PR. For more information, seedocs/how-to/bors.md
.