client: Fix CAS writes and buffer cleanup with write-back and immediate_commit #196
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:cas-writeback-immediate-commit"
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
Two client fixes for the write-back cache on immediate_commit=all pools. The new test needs both.
execute_cas()forced a SYNC before a CAS write over dirty write-back data only when the pool's immediate_commit is not "all". So on an immediate_commit=all pool withclient_enable_writeback, the CAS write went to the OSD first and succeeded against the old version. The older cached write then overwrote it at the next flush: the CAS write was lost although it had returned success. The fix adds the|| enable_writebackterm that the other four write-back checks in cluster_client.cpp already have.2e223f03a flush op carries itsflush_id. Socontinue_rw()marks the flushed buffers as written before the flush callback runs, and thedelete_flush()added by21066a09finds nothing. With immediate_commit no SYNC removes them later, so they stay for good. The leak21066a09fixed is back, and reads are answered from these buffers with version 0, so a CAS write retried after -EINTR never sees the real version.Who is exposed: only clients with
client_enable_writebackon immediate_commit=all pools. The KV database mixes CAS block writes with plain writes to the same blocks (clear_block()with version 0), so (1) can lose a block update there. Block clients (QEMU, NBD, ublk) send no CAS writes, but (2) keeps their written-back buffers forever.Found: seen in a test run. test_cas failed with "CAS write data lost" when run with the client write-back cache on an immediate_commit=all pool. With the first fix alone it failed with "CAS write failed to invalidate the write-back cache and read returned version 0", which led to the second fix.
Tested:
IMMEDIATE_COMMIT=1 ./test_cas.shis added to run_tests.sh, and test.yml is regenerated with tests-to-yaml.pl. It fails on master, fails with only the first commit, and passes with both../test_cas.sh,IMMEDIATE_COMMIT=1 ./test_kv_stress.shand test_cluster_client pass.-direct) on an IMMEDIATE_COMMIT=1 stand passes.Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA