Repository navigation
Conversation
Add src/test/formal/p, P models of correctness arguments in RGW, with rgw_overwrite: a model of PutObject, DeleteObject, CopyObject with a shared tail, part uploads, multipart completion and abort, lifecycle's abort, bucket listings and their repair, dedup, a logrecord reshard, the bucket index entry and its header stats, cls_refcount and GC. Its specifications check that no head's data is deleted, that the index lists what the head holds, that the stats match the index, that nothing leaks, and that every request is answered. Each mechanism the code relies on is a flag, as on main by default. Turning one off reproduces the code before the commit that added it, and the checker finds the bug that commit fixed. Faults and assumptions are flags too: a crash after the head write, a failed meta delete, a failed index completion, a request that stalls past the pending-op expiry, a completion lock that lapses under its holder. On main the model finds eleven problems, filed as tracker issues 80894 to 80903; the README traces each to the code. It also checks the fixes proposed for them, alone and all together, with and without failing index completions: every scenario holds but dedup's. The models are not part of the build: they need the .NET 8 SDK and the P tool. run.sh checks every case of a model against its expect.txt. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyle Bader <[email protected]>
PutObject and CompleteMultipartUpload may now carry If-Match, with an ETag or *, or If-None-Match: *, and DeleteObject If-Match with an ETag. A conditional write reads the head, checks the condition against it (check_preconditions) before its index op, and writes once: guarded on the ID tag it read, or as an exclusive create under If-None-Match: *. A lost race is answered as done_cancel maps it: 412, success, or the error itself, which is 404 or 500. A conditional delete checks the head it read, and on main its removal does not check it again. A new spec, CondSemantics, checks that a conditional request is answered as some order of the requests on its key would answer it, and that one answered 412 or 404 changed nothing, neither a head nor an index entry. Seven scenarios mix conditional and unconditional requests on one key, on main, with the fixes together, and with index completions that may fail. On main the model finds three gaps, traced to the code in the README: - A conditional DeleteObject racing a PutObject deletes the new object, whose ETag does not match: the removal has no ID-tag guard (finding 5). The guarded removal closes it. - A conditional request that loses the race is answered success even when the write that beat it needed the head it read, so no order of the two explains both answers: If-Match: * on main, and a conditional delete once its removal is guarded. - A completion refused after it lost the race removes its parts' index entries, though the upload stays. Two proposed flags close the last two: condLossFails answers such a lost race with an error, and refusedKeepsParts cancels a refused write's index op without remove_objs. With both and the seven fixes, every conditional scenario holds. A completion refused after it recorded its tag (completionMark) clears the record, so that a retry can still complete the upload. All 213 cases match expect.txt. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyle Bader <[email protected]>
| A model of writes to the keys of a non-versioned bucket that already hold | ||
| objects. A key is overwritten by PutObject, CopyObject or a multipart | ||
| completion, or removed by DeleteObject. Those operations race each other, | ||
| part re-uploads, aborts, lifecycle, dedup, bucket listings, a reshard and |
There was a problem hiding this comment.
s/a reshard/resharding/ perhaps?
A request in the model now ends with RGW's answer, not just success or failure. Each exit's op_ret goes through the op's send_response and rgw_http_s3_errors to an HTTP status and an S3 error code, including the 500 UnknownError that an errno with no S3 error gets. A new spec, S3Answers, checks each answer against AWS's Smithy model of S3 (aws/api-models-aws at f9dcea01) and the S3 User Guide's pages on conditional requests: the operation's success status, the errors its model and documentation name with their statuses, and that a conditional DeleteObject answered 204 removed an object. The completion now checks each part and cleans up its history in RGW's order. On main the spec finds two new gaps, traced to the code in the README: - A conditional DeleteObject that finds no object is answered 204, where S3 answers 404 (finding 15). - A completion refused after it checks a part has already sent the part's past prefixes to GC. Once GC runs, every upload of that part is refused with 409 BucketAlreadyExists (finding 16). It also shows how findings 2 and 13 look to a client: under If-Match a lost race is answered 500 UnknownError, and a completion whose meta object lifecycle deleted is answered 404 NoSuchKey. Two proposed flags close the new gaps: condDelNoKey answers a conditional delete that finds no object 404, and historyAfterHead sends the history to GC only once the head is written. With them and the earlier fixes, every S3Answers scenario holds. 72 new cases; all 285 match expect.txt. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: Kyle Bader <[email protected]>
|
this seems like a neat idea, but i don't know how to validate whether this model is accurate or complete. and if it is, how do we ensure the model gets updated (correctly) as we make design changes in the future? was this primarily to help debug/validate your other fixes, or do you think we should merge and maintain this? |
Extend rgw_overwrite in three directions. The model on main had no versioning, one index shard per layout generation, and no request that changes a head's attributes. The changes follow review of PRs 72096 to 72118, PR 70053 (ordered bucket indexes), and mheler's review of PR 72101. Versioned buckets ----------------- A version instance of a key is a head slot of its own, with its own bucket index entry. Key k itself is its null instance. VKEY(k, rid) is the instance that request rid writes when versioning is enabled. - A read without a version id (eReadCurrent) finds the current version, the present instance written last. This stands in for the olh. - PutObject and CompleteMultipartUpload write a new instance when versioning is enabled (an exclusive create that replaces nothing), and the null instance when it is suspended (which replaces the null version and sends its manifest to GC). - In a versioned scenario, DeleteObject names the version it deletes. - The config field versioning is VER_OFF(), VER_ENABLED() or VER_SUSPENDED(). The completion record of finding 3 (PR 72103) now carries the version instance the completion writes. markVersioned selects how a versioned bucket treats the record: - MV_SKIP(): no record, as PR 72103 first did. It tested bucket->versioned(), which is also true when versioning is suspended. - MV_CURRENT(): the record is checked against the current version. - MV_INSTANCE(): the record names the instance, and the check reads it. New scenarios: SC_DEL_AFTER_RETRY (a completion, a retry of it, then the first completion's version deleted) and SC_PUT_THEN_ABORT (a completion, a PutObject, then an abort). tcV<E|S><Pr|Cur|Inst><Crash|MetaDel> <Scenario> runs eight multipart scenarios with RGW crashing, or the meta delete failing, after the head write. Results: - Enabled, MV_SKIP(): violated in five scenarios. A retry writes a second version that shares the first one's parts, and an abort sends the parts of a completed version to GC. - Suspended, MV_SKIP(): violated in seven scenarios, as in a bucket that is not versioned. - MV_CURRENT(): holds when suspended. When enabled it is violated in PutThenAbort: after a later PutObject the completed version is not current, and the abort sends its parts to GC. - MV_INSTANCE(): holds everywhere, also at 100,000 schedules. Sharded bucket indexes ---------------------- A layout has one or two shards and is hashed (BucketHashType::Mod) or ordered (PR 70053). The config gives the layout before a reshard (srcShards, srcOrdered) and after it (dstShards, dstOrdered). The checker chooses each name's hash, and where an ordered layout splits: between the multipart names and obj1, or between obj1 and obj2. - Every index op places an entry by its object's name, or by the hash source of a multipart entry. So a key's versions, and its uploads' meta and part entries, share its shard in both layouts. - Each multipart entry records its shard. An op removes an entry only on the shard of the entry's object under the current layout. At the end, an entry on any other shard is orphaned, even while its upload lives. - A reshard to an ordered layout cannot keep a reshard log, so it blocks index ops from the start. A reshard from ordered to ordered is not allowed, and not modelled. - reshardByIndexName: a reshard places each entry by its full index key name, as PR 70053's reshard_process does (get_index_key_name), not by its object's name, as calc_target_shard on main does. A multipart entry's name, "_multipart_<obj>.<upload>...", hashes and sorts apart from its object's name. - The reshard's incremental pass now treats version instances as object keys (IsMainKey). New scenarios: SC_RESHARD_THEN_COMPLETE and SC_RESHARD_THEN_ABORT. tcSh<layouts><Obj|Idx>[VE|VS]<Scenario> runs five layout changes (H1H2, H2H2, H2O2, O2H2, H1O2) with both placements, versioned or not. Results: - Obj: holds in every layout change and scenario, apart from VsDel. - Idx: NoOrphans violated in ThenComplete, ThenAbort and VsMpu, in every layout change, hashed to hashed included. The completion or abort removes the upload's entries from its object's shard, and the reshard put them on another one. ListMultipartUploads then shows an upload that is gone. - VsDel is violated on main under either placement. This is finding 5: the reshard holds the DeleteObject's index prepare until its commit, which widens the window between its head read and its unguarded head removal. With the removal guarded (deleteGuard, PR 72100) it holds (tcShGuardH1H2ObjVsDel). Attribute updates ----------------- PutObjectTagging, PutObjectAcl and the other set_attrs callers change a head's attributes and keep its object. set_attrs guards the update on the ID tag it read (append_atomic_test) and sets a new ID tag. - New request R_SET_TAGS (eHeadSetAttrs): read the head, prepare the index op, set the tag set under cmpxattr on the ID tag read with a new ID tag, then complete the index op from the head read. An ACL update takes the same path. - tHead records the request whose user metadata the head carries (meta), and the request whose tag set it carries (tags). A copy onto itself replaces the metadata and copies the tag set, as x-amz-tagging-directive COPY does. A copy to another key copies both. - New spec AttrsKept: a copy onto itself and a tagging update of one key, each answered success, are both in the object at the end, whichever came first. It is checked for a key that no other request wrote. - copySelfRetries (proposed): a copy onto itself that loses its guard reads the head again and retries up to twice, and is answered 500 if it still loses. New scenarios: SC_COPY_SELF_VS_TAG, SC_TAG_VS_PUT and SC_TAG_THEN_COPY_SELF. Results for tcAttr<Main|Guard|Retry><Scenario>: - Main: AttrsKept violated. The copy writes back the tag set it read, losing the tagging update, or it loses its own guard to the update and is answered success without writing. - Guard (PR 72101): AttrsKept violated. The update's new ID tag fails the copy's guard, and the copy is answered success without writing, so its metadata is lost. mheler reported this on PR 72101. A vstart run reproduces it for tagging and for ACLs. - Retry: holds, also at 100,000 schedules. It also keeps finding 7 (a copy onto itself racing a PutObject) closed. Checks ------ All 498 cases in expect.txt match at 20,000 schedules. The README describes each extension, its test cases and its results, and lists what is not modelled. That includes delete markers and conditional writes of a version, more than two shards, and PR 70053's second op that writes a hashed-to-ordered reshard's split points. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Kyle Bader <[email protected]>
Move rgw_overwrite's Driver, its RGW return codes (tRc) and its script helpers (One, Two, Three) to common/Common.p, so that other models can use them. A model that includes Common.p defines the types tCfg, tReq, tInit and tOut, the functions InSlot, OutSlot and FirstRid, and the machines Store and Rgw. The Driver can now hand an answer from one phase to a later one: an answer fills a slot, and a later request takes that slot as its input. rgw_overwrite uses no slots, so it behaves as before. run.sh and deep.sh also find a .NET in ~/.dotnet, where the dotnet-install script puts it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Kyle Bader <[email protected]>
rgw_iam_sts models one account's roles, users and their access keys, groups and their members, with inline and managed policies, and the STS operations that issue and accept temporary credentials: AssumeRole, GetSessionToken, and S3 requests signed with an access key or with session credentials. Requests race each other one RADOS op at a time, and an RGW can die between any two ops. The model follows main at 504b1a2. Its contract is AWS's Smithy models of IAM and STS. common/Rados.p holds the RADOS semantics the Store uses: metadata objects under an RGWObjVersionTracker or an exclusive create, and the cls_user account resource omaps. The properties: a delete removes only an empty entity and takes effect; the indexes match the entities; account limits hold and names are unique; no update is lost; only active keys and trusted callers get in; a role's sessions die with it; and each answer is one that the operation's Smithy model lists. On main the model finds sixteen problems, described in its README. Each proposed fix is a configuration flag, and the README maps the issues filed for the problems without a security impact (tracker 81345 to 81354) to their fixes: - 81345 roleDeleteById, 81346 roleWriteNeedsRole - 81347 and 81348 limitAtomic - 81349 and 81351 groupLinkGuarded, 81350 renameMovesMembers - 81352 assumeDeniesMissing, 81353 userDeleteNeedsNoGroups - 81354 retriesOutServiceFailure, or retries with no limit Every scenario without crashes holds with all the fixes. It also holds when the fixes use only the ops that RADOS and cls_user offer today (existingOpsOnly), so none of them needs a new op. expect.txt lists 123 cases. ./run.sh rgw_iam_sts checks them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Kyle Bader <[email protected]>
|
This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days. |
A P model of RGW's write paths, which found the races fixed in #72097 through #72103 and #72109.
src/test/formal/p/rgw_overwritemodels PutObject, DeleteObject, CopyObject with a shared tail, conditional requests (If-Match, If-None-Match: *), part uploads, multipart completion and abort, lifecycle's abort, bucket listings and their repair, dedup, a logrecord reshard, the bucket index entry and its header stats,cls_refcountand GC, each step at the granularity of a RADOS operation. Its specifications check that no head's data is deleted, that the index lists what the head holds, that the stats match the index, that nothing leaks, and that every request is answered. The checker searches the interleavings of a few requests on one or two keys, with faults: a crash after the head write, a failed meta delete, a failed index completion, a request that stalls past the pending-op expiry, a completion lock that lapses under its holder.Each mechanism the code relies on is a flag, as on main by default; turning one off reproduces the code before the commit that added it, and the checker finds the bug that commit fixed (for example #75375's without lock renewal). On main the model finds fourteen problems. The first eleven are filed as https://tracker.ceph.com/issues/80894 to https://tracker.ceph.com/issues/80903; its README traces each to the code and lists the proposed fix. It also checks those fixes alone and all together, with and without failing index completions: every scenario holds but dedup's (https://tracker.ceph.com/issues/80901, open). Findings 12 to 14, on conditional requests, reproduce on a cluster too (https://tracker.ceph.com/issues/80898, https://tracker.ceph.com/issues/80906, https://tracker.ceph.com/issues/80907); their fixes are #72100 and #72109.
The models are not part of the build: they need the .NET 8 SDK and the P tool.
./run.sh rgw_overwrite 20000 <jobs>checks all 213 cases againstexpect.txt; all match. The reproducers on a cluster are in #72096 and #72097.Checklist