osd: don't let a timed-out PG state report overwrite a newer one #183
Open
koolkhel
wants to merge 2 commits from
koolkhel/vitastor:pg-state-stale-txn into master
pull from: koolkhel/vitastor:pg-state-stale-txn
merge into: vitalif:master
vitalif:master
vitalif:primary-stickiness
vitalif:libvfn
vitalif:canceling
vitalif:immediate-repeering
vitalif:rdma-close-tcp
vitalif:use-degraded-writes
vitalif:fix-write-delete-flow
vitalif:openssl-3.0.12
vitalif:openssl-capture-secrets
vitalif:ignore-small-rdma-end
vitalif:encrypt-batch
vitalif:faster-peering-calc
vitalif:http-hello
vitalif:xxh3-bench
vitalif:create-user-etcd-based
vitalif:aesxts_streaming_nosupport
vitalif:refactor-heap-continue-write
vitalif:ston3lu-patch-0127
vitalif:rdma-credits
vitalif:heap-meta
vitalif:sendmsg-zc-no-more-error
vitalif:fix-clear-refs
vitalif:veeam-trick
vitalif:test-etcd-schizo
vitalif:test
vitalif:test1
vitalif:test2
vitalif:cow-meta
vitalif:kv-readahead
vitalif:qemu-fix-crash-idea
vitalif:eventloop-auto-init-trigger
vitalif:hugo-docs
vitalif:node-mutex-and-postpone
vitalif:check-writeback
vitalif:msgr-iothreads-v2
vitalif:antietcd
vitalif:rel-1.4
vitalif:test-fix-ec-unknown-state-51
vitalif:kv-update
vitalif:kv-debug
vitalif:hotfix-1.2.0
vitalif:rdma-simple-nodp
vitalif:zerocopy-tcp-send
vitalif:csi-staging
vitalif:hotfix-1.1.0
vitalif:hotfix-1.0.0
vitalif:fsync-feedback
vitalif:cached-reads
vitalif:qemu-send-loop
vitalif:test-double-alloc
vitalif:hier-failure-domains
vitalif:mon-self-restart
vitalif:epoch-deletions
vitalif:rdma-flow-control
vitalif:csi-use-vitastor-cli
vitalif:rdma-v2
vitalif:etcd-hide-base64
vitalif:lrc-matrix
vitalif:rm-left-on-dead
vitalif:nfs-proxy-old
vitalif:non-odp-rdma
vitalif:test-zctr
vitalif:separate-data-connections
vitalif:sec_osd_msgr
vitalif:test-assert
vitalif:nbd-vmsplice
vitalif:allow-etcd-address-option
vitalif:rdma-zerocopy
vitalif:rel-0.5
vitalif:openonload
vitalif:sync-io-test
vitalif:trace-sync
vitalif:trace-sqes
vitalif:test-submit-and-wait
vitalif:test-sq-poll
vitalif:blocking-uring-test
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
No description provided.
Delete Branch "koolkhel/vitastor:pg-state-stale-txn"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
A PG state report that timed out on the client may still be applied by etcd after the newer report sent by the retry. The HTTP client closes the connection on timeout and the retry goes to the next etcd address, so the old txn can reach the raft log after the new one. Its only compare for an existing key,
LEASE == ours, holds for every write of this OSD process. The old txn then put back an old state (peering) or deleted the key of an active PG (anofflinereport). The OSD never wrote the key again: nothing marks the PG dirty, andapply_pg_config()skips an unchanged PG. So the PG stayedoffline(no key) orpeeringin etcd, and the pool stayed inactive until the OSD restarted.The fix adds
MOD < max(etcd_watch_revision_pg, revision of our last successful report) + 1next to theLEASEcompare, like the/pg/historyput already does. A txn built before a newer write now fails if etcd applies it later. The revision of our own last write comes from the txn response, so back-to-back reports (peering -> active) don't wait for the watcher. After a timeout whose txn was applied, the next report fails until the watcher delivers that revision, the same as theVERSION 0case does today.On a failed compare, the OSD now also prints the state keys that failed it: the value, lease and mod_revision found, and what was expected. Before this, the error line carried an empty message and said nothing about which compare failed.
Not covered: a timed-out
VERSION 0create (the first report of a PG that has no key yet) that lands after the OSD has stopped the PG, reportedoffline(deleting nothing) and forgotten it. The key then names this OSD as primary of a PG it doesn't hold, and the new primary won't take it until this OSD's lease ends. A compare on the key alone can't reject that create. It would need the OSD to delete state keys that name it for PGs it doesn't hold.Found: the symptom was seen on a 16-node test stand with 3840 OSDs at cold start with etcd overloaded: in 1 run of 2, 4 PGs had no /pg/state key, or a stale "peering" one, for more than 9 minutes. The cause is inferred from the code; it was not confirmed on that stand.
Tested:
osd_test. The newtest_stale_pg_state_reportfails without the fix (the old txn succeeds and putspeeringback). With the fix all 80 tests pass, and the other tests show the same report errors as before. The race wasn't reproduced against a real etcd; the test reproduces it with the etcd mock.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
A PG state report that timed out on the client may still be applied by etcd after the newer report sent by the retry, which goes to the next etcd address. Its only compare, LEASE == ours, holds for every write of this OSD, so the old txn put back an old state ("peering") or deleted the key of an active PG, and the OSD never wrote it again: the PG stayed "offline" or "peering" in etcd until the OSD was restarted. Also require the state key to be unchanged since our last successful write, like the /pg/history put already does, and print the state keys that failed a compare.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.