-
Notifications
You must be signed in to change notification settings - Fork 673
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
Fix migrations check at startup with a read-only connection #1656
Conversation
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.
LGTM, but I think that this check is only done for the StateDB, it would be nice to do it for the PoolDB as well
EDIT: you can create issue and do this in a future PR if you prefere
@arnaubennassar As far as I know we can not have the pool db in readonly mode because the rpc needs to store new transactions on the pool db. Maybe we need to allow the rpc to handle read and write replicas. For instance, if the request is for getting if the gas price, then it should use a read replica, if the method is eth_sendRawTransaction, then it should be able to write into the pool db |
@ARR552 I tested this on
I didn't face any issue with this implementation. In addition, I added a log message to inform that the check has been successful b4aebed WDYT? |
Closes #1653.
Background
The
rpc
node is supposed to connect to thestate
database using a read-only connection, in order to not overwhelm the RW connection. This is made possible by the changes introduced in #1531 that allow therpc
node to not run migrations.What does this PR do?
Unfortunately it turns out that the
sql-migrate
library requires a RW connection even for tasks that do not actually run the migrations. In our case we were callingmigrate.PlanMigration
andmigrate.GetMigrationRecords
but both fail on a RO connection.To overcome this, here the proposal is to directly query the migrations table and compare the number of migrations found there with the number of
Up
migrations in our source code (by inspecting list the returned bymigrationSource.FindMigrations()
).The solution has been tested to be working on the
develop
testnet. It may sound a bit "hacky" and thus alternative ideas/approaches are welcome.Reviewers
Main reviewers: