khepri
khepri copied to clipboard
Always pass exported functions to Ra queries
Why
Using fun()
is fragile if it has to be executed on a remote node. Indeed, the remote node may have another version of the module hosting the function and the function reference may be invalid.
How
There are two parts:
- We always use an exported function inside Khepri.
- We ensure that the caller of folding APIs passes MFA if they request leader or consistent queries.
fun()
are only accepted for local queries.
Fixes #238.
Codecov Report
Attention: 3 lines
in your changes are missing coverage. Please review.
Comparison is base (
b75785f
) 88.74% compared to head (f02a92b
) 89.37%.
Files | Patch % | Lines |
---|---|---|
src/khepri_machine.erl | 95.23% | 2 Missing :warning: |
src/khepri.erl | 96.55% | 1 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## main #242 +/- ##
==========================================
+ Coverage 88.74% 89.37% +0.63%
==========================================
Files 20 21 +1
Lines 2896 3079 +183
==========================================
+ Hits 2570 2752 +182
- Misses 326 327 +1
Flag | Coverage Δ | |
---|---|---|
erlang-24 | 88.34% <98.66%> (+0.66%) |
:arrow_up: |
erlang-25 | 88.34% <98.66%> (+0.66%) |
:arrow_up: |
erlang-26 | 88.98% <98.66%> (+0.62%) |
:arrow_up: |
os-ubuntu-latest | 89.34% <98.66%> (+0.60%) |
:arrow_up: |
os-windows-latest | 89.08% <98.66%> (+0.68%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
The patch is finished but I would like to test it with RabbitMQ before merging it.
I have second thoughts on the fact that MFAs are good enough as a solution to execute code remotely. Yes, with the current patch, we ensure that a query won’t break because the function reference is invalid on another node. But that doesn’t mean that the function exported remotely is the same as the local one. This is quite unintuitive.
Thinking out loud here; if a leader query was requested, what about we check the cursor on the leader, wait for the local cursor to catch up, then execute the query function locally? Don’t we have the same consistency guaranty? It may take more time to answer the query though, because the catch up can be longer than a remote execution.
This pull request was superseded by #260.