mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-06 11:07:31 +01:00
Reject computed statuses in the conflict census
This commit is contained in:
1 parent
c3c58986e2
commit
0ff18a72ae
2 files changed
+30
-3
No files matched your search
@@ -84,8 +84,19 @@ func unclassifiedChunkConflicts(source []byte) ([]string, error) {
|
||||
case "catalogStatus(ce.Code)", "remembered.status":
|
||||
key = status + ":" + code
|
||||
default:
|
||||
// A new computed status needs review too: it could return a 409.
|
||||
if !strings.HasPrefix(status, "http.Status") {
|
||||
// Only these exact selector ASTs prove a reviewed non-409
|
||||
// status. A computed expression with the same textual prefix
|
||||
// (including StatusConflict + 0) needs classification.
|
||||
allowed := false
|
||||
if sel, ok := ret.Results[0].(*ast.SelectorExpr); ok {
|
||||
if pkg, ok := sel.X.(*ast.Ident); ok && pkg.Name == "http" {
|
||||
switch sel.Sel.Name {
|
||||
case "StatusGone", "StatusServiceUnavailable", "StatusNotFound", "StatusBadRequest", "StatusInternalServerError":
|
||||
allowed = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if !allowed {
|
||||
missing = append(missing, "unreviewed status: "+status)
|
||||
}
|
||||
return true
|
||||
@@ -132,3 +143,18 @@ func TestChunkConflictCensusRejectsANewUnclassifiedCode(t *testing.T) {
|
||||
t.Fatalf("new code escaped census: %v (%v)", missing, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestChunkConflictCensusRejectsComputedStatus(t *testing.T) {
|
||||
source, err := os.ReadFile("chunk_control.go")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
mutated := bytes.Replace(source, []byte(`return http.StatusConflict, "cut_busy", true`), []byte(`return http.StatusConflict + 0, "cut_busy", true`), 1)
|
||||
if bytes.Equal(source, mutated) {
|
||||
t.Fatal("computed-status control did not mutate the mapper")
|
||||
}
|
||||
missing, err := unclassifiedChunkConflicts(mutated)
|
||||
if err != nil || len(missing) != 1 || !strings.Contains(missing[0], "unreviewed status") {
|
||||
t.Fatalf("computed 409 escaped census: %v (%v)", missing, err)
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,8 @@ second non-idempotent operation after an uncertain answer.
|
||||
| Snapshot observation: succeeded without a result, at admission or poll | 1 | 3 with `outcome_unknown` | Recover the original request id/handle; the incomplete observation does not settle it. |
|
||||
| Plain detach: malformed seal result | 1 | 3 with `outcome_unknown` | Retry the same plain detach to settle it; the reply does not prove the sealed HEAD. |
|
||||
| Snapshot observation: JSON decoder failure | 75 | 3 with `outcome_unknown` | Recover the original operation; malformed data does not settle it. |
|
||||
| Initial HTTP answer: complete malformed or oversized failure body | 1 | 1 / 2 / 3 / 5 | Received 4xx other than 429 retains its auth/argument/refusal class; 429, 5xx, other non-200 answers and an oversized successful/admission answer are UNKNOWN/3. An unreadable body never erases the response status or proves the sent operation failed. |
|
||||
| Initial HTTP answer: unusable 4xx failure body, except 409/429 | 1 | 1 / 2 / 5 | Preserve the received auth/argument/refusal class; do not infer it from a nested transport error. |
|
||||
| Initial HTTP answer: unusable 409/429, 5xx, other non-200 answer, or oversized success/admission | 1 | 3 with `outcome_unknown` | These statuses cannot settle the original operation. Recover using the same request id/replay key or existing handle; an unusable 409 does not prove non-admission or that nothing applied. |
|
||||
| Snapshot admission: invalid identity/body or unsafe operation URL | 1 | 3 with `outcome_unknown` | Refuse the unsafe URL and retain the original request id; retry that id against the original status address. |
|
||||
| Snapshot observation: interrupted after admission | 1 | 3 with `outcome_unknown` | Preserve the original request id and handle; resume that operation instead of starting another one. A valid terminal answer still takes precedence. |
|
||||
| Chunk verify: incomplete lost answer | 75 for transport; 1 for other incomplete failure | 1 with JSON `outcome_unknown` | Read-only retry is safe; **3 is reserved for a completed scan with findings**. Proven unsent/retryable remote failure remains 75. |
|
||||
|
||||
Reference in new issue
Block a user