-
Notifications
You must be signed in to change notification settings - Fork 913
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
db_write
hook chaining
#4219
Comments
ZmnSCPxj
added a commit
to ZmnSCPxj/lightning
that referenced
this issue
Nov 23, 2020
Fixes: ElementsProject#4219 Changelog-Changed: Plugins: Multiple plugins can now register `db_write` hooks.
ZmnSCPxj
added a commit
to ZmnSCPxj/lightning
that referenced
this issue
Nov 23, 2020
Fixes: ElementsProject#4219 Changelog-Changed: Plugins: Multiple plugins can now register `db_write` hooks.
rustyrussell
pushed a commit
that referenced
this issue
Nov 30, 2020
Fixes: #4219 Changelog-Changed: Plugins: Multiple plugins can now register `db_write` hooks.
vibhaa
pushed a commit
to spider-pcn/lightning
that referenced
this issue
Mar 24, 2021
Fixes: ElementsProject#4219 Changelog-Changed: Plugins: Multiple plugins can now register `db_write` hooks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
db_write
would appreciate chaining: more backups == better.More specifically,
db_write
would appreciate parallel chaining. Eachdb_write
plugin really just returns an "ACK"/"NAK"; if any "NAK", we abort. Since a good backup plugin would first check that the replica has confirmed complete receipt of a set of queries, it would block until it does so. If we did chaining the "normal" way, then having two backup plugins would have us hand over the data to one of them, wait for its replica to confirm receipt, then hand over the data to the other, and wait for its replica to confirm receipt.So, we should send out
db_write
to all hooked plugins in parallel.We could modify
db_write
, which has its ownio_loop
over inplugin_exclusive_loop
, to instead have an exclusive loop over multiple plugins. We iterate over all registered plugins and create requests to them (it would be nice if we could make the JSON request once and just clone it; is there a function already for that?), set a counter to the number of registered plugins, then enter an exclusive loop for all of them. Thedb_hook_response
, if the response is{"result":"continue"}
then decrements that counter and only breaks out of the loop if the counter is 0, thus resuming operations.Of course, if one of the replicas goes down, the others will have replicated a set of queries that the downed replica does not. This should be fine. If the downed replica is brought up and then
lightningd
is restarted then the version will be repeated and the other replicas will reverse their last transaction; if thelightningd
is recovered from any of the surviving replicas then it gets to see that transaction but will behave as if it had an abnormal shutdown after the transaction but before it could send any messages to peers, which we should also handle properly (the protocol provides for this).As best I can determine (so far) it seems safe to binary-copy an SQLITE3 database during a time when
db_write
is blocked waiting for a response from a plugin.A parallel invocation of
db_write
does mean that the newfangledbefore
andafter
specs are pointless for thedb_write
hook.The text was updated successfully, but these errors were encountered: