Skip to content
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

Is this a bug at check-account in stolon/src/jepsen/stolon/ledger.clj ? #562

Open
HaxiSnake opened this issue Nov 15, 2022 · 3 comments
Open

Comments

@HaxiSnake
Copy link

HaxiSnake commented Nov 15, 2022

Hi, I'm learning jepsen on postgres, and I notice a check rule in ledger.clj which confuses me.

`

(defn check-account
"Takes an [account, ops] tuple, and checks to make sure it has a non-negative
balance."
[[account ops]]
; When ops are indeterminate, we don't know if they took place or not. We
; have to take the most charitable interpretation: assume deposits succeed,
; withdrawals fail.
(let [deposits (filter (comp pos? second :value) ops)
withdrawals (filter (comp neg? second :value) ops)
balance (->> (concat deposits (filter op/ok? withdrawals))
(map (comp second :value))
(reduce + 0))]
(when (or (neg? balance) (pos? balance))
{:account account
:balance balance})))

`

This test is aimed at to check each banlance of the account is non-negative, why return result when banlance is pos?

`

(defn checker
[]
(reify checker/Checker
(check [_ test history opts]
(let [errs (->> history
(filter (comp #{:ok :info} :type))
(group-by (comp first :value))
(keep check-account))]
{:valid? (not (seq errs))
:errors errs}))))

`

this may lead to that it will be recognized as errors when checking, Am I reading this correctly?Thanks for your attention.

@aphyr
Copy link
Collaborator

aphyr commented Nov 15, 2022

Entirely possible this is wrong--just going through the namespace again, this looks like it may have been a work-in-progress I was sketching out but never finished.

@HaxiSnake
Copy link
Author

ok, thanks for your reply! But is this ledger case will be finished?

@aphyr
Copy link
Collaborator

aphyr commented Nov 16, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants