osd, cli: Pause writes while making a live snapshot #177
Open
koolkhel
wants to merge 5 commits from
koolkhel/vitastor:readonly-inode-check into master
pull from: koolkhel/vitastor:readonly-inode-check
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:readonly-inode-check"
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 live snapshot is one etcd transaction: the image's inode is renamed into the snapshot and marked readonly, and a new top layer is created. Clients and OSDs learn about it from their own etcd watches, each at its own moment.
readonlyis checked only on the client, so a client that is late keeps writing into the snapshot, and OSDs accept it. With several clients writing to one image, the snapshot can then hold a write while missing an earlier one it depends on, and writes made after the snapshot are missing from the image.What the PR does:
snap-createfirst sets a newpausedflag in the image's inode config and waits until every primary OSD reports, in a newconfig_revisionfield of its/osd/state, a revision at or above that change. An OSD rewrites its/osd/state(under its lease) only when it applies a config change with a paused inode, or finds one when it loads PGs. Thensnap-createmakes the snapshot as before, records the new top layer in the snapshot's config assuccessor_id/successor_pool(encoded likeparent_id/parent_pool) and drops the pause.--pause-timeoutseconds (10 by default), or the snapshot fails,snap-createremoves the pause. If it is killed while writes are paused, repeating it makes the snapshot. If some primary OSD doesn't reportconfig_revisionat all (an older version), it warns and snapshots without pausing.readonly_checkfeature inSHOW_CONFIG. A PG primary rejects WRITE/DELETE from such a client to a paused inode, or to a readonly inode with a successor, with-ESTALE(-EROFSfor CAS writes). Older clients get no new error codes and behave as before.-ESTALEwrite until its own view shows the snapshot, then resends the whole write to the successor, following several snapshots if it missed them. Withimmediate_commitother thanall, the copy kept for replay moves with it. It warns only if it waits longer than 10 s.OSD_OP_IGNORE_INODE_READONLY(8) and aren't checked.etcd_watch_delay_msapplies watch events that much later, in order, so a lagging client or OSD can be made deterministic in tests.New in the protocol and in etcd: rw flag 8, the
readonly_checkfeature, the inode config fieldspaused,successor_idandsuccessor_pool, andconfig_revisionin/osd/state. No new opcodes.Not covered: clients without
readonly_checkaren't paused or redirected, so with them a live snapshot is consistent only with a single writer, as before.Found: by reading the code (
readonlyis checked only on the client), then reproduced by delaying etcd watch events on one client.Tested:
osd_test(test_readonly_check: rejection for a paused inode and a snapshot, the/osd/staterewrite),test_cluster_client(test_ignore_readonly_flag,test_stale_write_follows_successor), andtests/test_snapshot_switch.sh, also withIMMEDIATE_COMMIT=1. That test has three parts. Two clients write acrosssnap-create, one of them applying etcd events 3 s late, and the snapshot must not change afterwards. Then all OSDs apply etcd events 3 s late too:snap-create --pause-timeout 1must give up and leave nothing paused, and writes sent right aftersnap-createmust not reach the snapshot. Without the pause step, the last part fails with "Snapshot s2 got writes made after it".tests/test_rm.shpasses.test_snapshot*.shpass up to the point where they needqemu-imgwith the vitastor driver, which the test host doesn't have.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA
9dc06ed9e4tobef72607cdosd, client: Reject writes to snapshots from clients that missed the switchto osd, cli: Pause writes while making a live snapshotReworked as we discussed: the OSD-side refusal stays, and the snapshot now waits for the OSDs.
pausedflag in the inode config,config_revisionin/osd/state(rewritten under the lease only when the OSD applies a paused inode), andsnap-createin three steps (pause, wait for every primary OSD, snapshot), with--pause-timeout.successor_id/successor_pooland the client resend are unchanged; the OSD now also refuses writes to a paused inode.tests/test_snapshot_switch.shnow also covers OSDs lagging behind etcd and two writers.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.