osd: Free the old object state in mark_object() only after inserting the new one #169
Open
koolkhel
wants to merge 1 commits from
koolkhel/vitastor:mark-object-reuse into master
pull from: koolkhel/vitastor:mark-object-reuse
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:mark-object-reuse"
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
mark_object()freed the object's old state entry (remove_object_from_state()+deref_object_state()) before it inserted the new one (add_object_to_set()). When the object is alone in its state and nothing else holds the entry, thestate_dictnode is freed and the very next insert gets the same block from malloc (glibc's tcache), so the new state has the old address. Callers detect a swap by comparing the pointers:continue_primary_read()retries a corrupted read only ifop_data->object_statechanged, so it sees "no change" and finishes with EIO although a healthy copy is left. The write path compares the same way. The read pin from3bf0b45adoesn't help:mark_object(ref=true)drops it before the insert.Example: replica 3, one copy already marked corrupted by an earlier read (the object alone in state {1 corrupted, 2, 3}); a read then gets EIO from the second copy. The second copy is marked, but the read returns EIO instead of reading the third one. Clients retry EIO after
client_eio_retry_interval, so the visible effect is a stall of about a second, not an error, unless the retry interval is 0.Fix: unlink the object from the old state, insert it into the new one, and release the old entry last, so the two can never share an address. Nothing between the two steps looks at the old entry:
state_dictis only walked at peering, and PG flags and counters come from the per-object maps thatremove_object_from_state()has already updated.The
if (ref)lines next to this change are the ones #158 touches; the hunks don't overlap.Tested: new
test_read_eio_retries_when_mark_reuses_stateinosd_test. Without the fix the second read fails with EIO and sends nothing to the third OSD (the old and new state pointers are equal); withGLIBC_TUNABLES=glibc.malloc.tcache_count=0the unfixed code passes, so the address reuse is the whole cause. With the fix the read retries on the third OSD and returns the data. The wholeosd_testpasses.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
Rebase
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.