-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[CHIA-683] Drop unknown tables when resetting wallet sync DB #18222
Conversation
my understanding is that there are two kinds of tables in the wallet DB:
This function is supposed to only delete the first kind, to be better than deleting the whole DB. I imagine a long term improvement would be to separate (1) and (2) into separate database files. With your change, is there a risk you delete tables of type 2? Did you dig through git and github history to try to understand the rationale for the error? I agree that it does sound a bit unintuitive at first glance. |
it seems reasonable to leave unknown tables in the database. The case where we downgrade and resync, we're syncing with the old version anyway, the unknown tables won't interfere with that. If we ever upgrade again, those tables may be useful if they are of type (2). |
We talked about this in a standup and did identify that both types of data exist in the database but none of it is critical, more for display. The practice of blowing away the wallet DB has been widespread for quite some time and this function as I remember it being presented at the time was just as a way to make that process more ergonomic and faster. I would agree in the future to separate out the two types of data and would assume it would be a dependency of any work that intended on adding some data of category (2) to the wallet. Like I said in the PR description, the approach here is taken for the purposes of having consistent behavior. When you use this function on a downgraded version, you get set to a known state for that version rather than leaving around some side effects whose form can become corrupted in any number of ways when switching from version to version. If you re-upgrade, that state is not likely to be very helpful and may actually be confusing because it contains state for a certain range of the blockchain and is missing some state for a range that we synced on a lower version. It's a much easier cognitive burden when trying to troubleshoot to say that when you re-upgrade, it's as if you've done it for the first time. |
Pull Request Test Coverage Report for Build 9846380723Warning: This coverage report may be inaccurate.This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.
Details
💛 - Coveralls |
In the wallet node, there is a function called
reset_sync_db
the purpose of which is to delete relevant information from specific wallet tables that gives you “sync state” so that you can try again if the wallet gets into a bad state.There’s a problem with this function, which is that it specifies a list of all existing tables and throws an error if any exist that are not mentioned in that list. When you add a table, you have to add it to that list in order for the function to work but if you downgrade then that addition is no longer in the code, but it the table remains in the DB and the function throws an error about an unexpected table.
The way I see it, there’s a few potential solutions, some more robust than others:
This PR takes the second approach to avoid the complexity of the third approach and provide more consistent behavior than the first approach likely provides.