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.
dbbackup: A minimal database backup plugin #40
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
dbbackup: A minimal database backup plugin #40
Changes from all commits
b7961e6
7ebc996
5856b61
de14f62
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
A better handling of this would be to just outright copy the original over the backup. Though it would not be safe to do so in the
init
as that is async. Instead, on the firstdb_write
afterinit
, that is when you do your overwriting the backup with the original. Though this is sensitive to the order in which C-Lightning writes to its own original copy (whether it does the write beforedb_write
or afterdb_write
). Might be more complicated than what you are willing to implement and I suppose the operator can manually do the copy in this edge case while C-Lightning is not running.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.
There is a potential (but unlikely) race condition where
db_write
is invoked beforeinit
, then C-lightning crashes before it is able toinit
the plugins. It may be safer to save these in a temporary file that you clear out onceinit
is invoked.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.
Good catch, though writes before the
init
call will all be migrations iirc, so these are not catastrophic.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.
Not keeping up with C-lightning upgrades is "not catastrophic"? Upgrades are a risk by themselves as they represent changed code, and the user might be running on some obscure combination of system components that happen to work on older releases of C-lightning but not on newer ones, so a new release (which is when we are likely to have migrations running) is at increased risk of crashes before
init
... shrugThere 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.
@ZmnSCPxj Thanks, there is also a potential dead-lock when the plugin makes the
rpc.stop()
call frominit
while at the same timelightningd
is waiting for adb_write
hook to return. TBH I was totally unaware that plugin with (sync) hooks shouldn't make any (sync) RPC calls, at least not from the same threat that also handles the hook.If I understand correctly, RPC calls can be send after jsonrpc_listen but are not be answered until the main io_loop_with_timers
To solve these and similar issues, I am exploring a sync init in plugins_config where
lightningd
waits for theinit
response of certain (perhaps all static?) plugins before continue startup, in a similar way as it does forgetmanifest
. And maybe shutdown CL when a plugin'sinit
returns False? Will make a PR if that doesn't break too much.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.
How does this cause a failure writing to the DB? I thought sqlite3 keeps an fd open to the db file, which is unaffected by moves.
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.
I have no idea, but it works . The error returned by sqlite3:
attempt to write a readonly database
Any other ideas how to emulate a disk-full scenario? (maybe loop device)