jepsen-io / jepsen

A framework for distributed systems verification, with fault injection
6.84k stars 718 forks source link

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

Open HaxiSnake opened 2 years ago

HaxiSnake commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

aphyr commented 2 years ago

I have no plans to revisit that particular code right now.On Nov 16, 2022 01:55, Dong @.***> wrote: ok, thanks for your reply! But is this ledger case will be finished?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>