Repository navigation
fix(cf-edit): keep Hub ACL authorization outside Branch(master) - #44
Merged
Merged
Conversation
cf-edit publication (optimistic save, commit, checkin) acquired Branch(master) FOR UPDATE and then called Hub /cloudfile/acl/check/ inside the same transaction through a client with a hard 5s timeout. A protected library therefore serialized every publication behind a remote ACL round trip, and a slow Hub blocked unrelated commits on the same repository. Run the bounded ACL row/revision proof and the single Hub write decision as a preflight before BeginTx, then verify the same proof with cfACLFinal() under the lock. Phase B performs no HTTP and no commit diff. Reviewed Hub ACL writers take the same Branch lock, so an ACL change between preflight and publication refuses the write instead of being bypassed. Verified locally: go build ./..., go vet ./..., targeted Go tests (TestCFEdit/TestCFACL/TestCFV2/TestUploadGuard) and the cheap Python source contract suite (21 tests) pass. Real MariaDB+Hub concurrency proof is still out of scope here and tracked in #43. Refs #43
cf_v2_acl_final_scoped() has no callers since #42 moved native CAS publication to the preflight/proof split. Keeping it is a trap: it runs cf_v2_acl_preflight_scoped() (including the Hub HTTP call) inside a caller transaction, which is exactly the lock/HTTP ordering this branch fixes. Delete the wrapper and its header declaration so the two-phase contract has a single entry point. No behaviour change for existing callers. Refs #43
opendev9
force-pushed
the
fix/cf-edit-publish-acl-lock
branch
from
October 25, 2026 07:10
f7e490c to
143678c
Compare
Author
CI 复核补充(C 编译与失败归因)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Fixes #43.
cf-editpublication (save/commit/checkin, including theoptimisticaction available with Checkout OFF) used to do this:BeginTxcfEditHead→SELECT commit_id FROM Branch WHERE ... FOR UPDATEcfEditCurrentPermission→cfACLAuthorize→ HTTP POST Hub/cloudfile/acl/check/with a hard 5s client timeoutBranch,CommitSo every publication of an ACL-protected library serialized on
Branch(master)behind a remote ACL round trip — the same defect class #42 fixed for original
commit / Branch CAS, but #42 did not touch
cf_v2_edit_agent.go.Change
Two-phase publication, reusing the contract #42 established (no new mechanism,
table, queue or second policy engine):
BeginTx):cfEditPermissionPreflightreads the boundedcf_dir_aclrow/revision proof (cfACLCurrentProof(..., locked=false)) and,only for a protected library, makes one Hub write decision for the exact path
(
cfACLAuthorize; the handler keeps its existing 403 mapping).cfACLFinalre-reads the same proof withcurrent locking reads and compares the SHA-256 digest. No Hub HTTP, no commit
diff, no object-store traversal under the lock.
VERSION_CHANGED,STALE_GUARD,CHECKED_OUT). A rule change between phases refuses the publication(
PERMISSION_CHANGED), matching perf(native): move C/Go ACL HTTP outside Branch transactions #42's fail-closed behaviour; reviewed Hub ACLwriters take the same
Branch(master)lock, so the proof is thelinearization point.
cfEditCurrentPermissionremoved (its only caller was this path).cf_v2_acl_final_scoped()and its header declaration. Keeping it invited theforbidden "Hub HTTP inside a caller transaction" use.
Files:
fileserver/cf_v2_edit_agent.go,common/cf-v2-acl.c,common/cf-v2-acl.h, plustests/test_cf_edit_publish_lock_scope.py(cheapsource-order contract that fails if a Hub authorization returns to the
publication transaction).
Verification
Local (PR head
143678c):go build ./.../go vet ./...— OKgo test . -run 'TestCFEdit|TestCFACL|TestCFV2|TestUploadGuard' -count=1— okpython3 -m unittest discover -s tests -p 'test_cf_*.py'— 21 tests OKgofmt -lclean;git diff --checkcleanManual
CloudFile checksdispatch (run 40171818858, C build + cross-repo):CC cf-v2-acl.ocompiled successfully after the wrapper removal.CloudFile V2 requires ENABLE_GO_FILESERVER=trueand thechecksjob fails oncloudfile-docker/tools/check-requirements.txt(path moved). A dispatch ofthe same workflow on plain
dev(run 40172403047) fails with the exactsame signatures, so both are pre-existing workflow/environment drift, not
introduced here.
Not verified / follow-up
/cloudfile/acl/check/, assertBranch lock wait excludes the Hub RTT) still needs an integration
environment;
tests/test_cf_v2_acl_native.pyis a__main__script and wasnot executed here.
Refs #42, #43.