{"record":{"id":"340ee5ac8a42d902","repo":"benbjohnson/litestream","slug":"oss-delete-all-batch-of-d-objects-w","errorCode":null,"errorMessage":"oss: delete all batch of %d objects: %w","messagePattern":"oss: delete all batch of (.+?) objects: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oss/replica_client.go","lineNumber":377,"sourceCode":"\t\t\tif obj.Key != nil {\n\t\t\t\tobjects = append(objects, oss.DeleteObject{Key: obj.Key})\n\t\t\t}\n\t\t}\n\t}\n\n\t// Delete all collected objects in batches\n\tfor len(objects) > 0 {\n\t\tn := min(len(objects), MaxKeys)\n\t\tbatch := objects[:n]\n\n\t\trequest := &oss.DeleteMultipleObjectsRequest{\n\t\t\tBucket:  oss.Ptr(c.Bucket),\n\t\t\tObjects: batch,\n\t\t}\n\n\t\tout, err := c.client.DeleteMultipleObjects(ctx, request)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"oss: delete all batch of %d objects: %w\", n, err)\n\t\t} else if err := deleteResultError(batch, out); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tobjects = objects[n:]\n\t}\n\n\treturn nil\n}\n\n// ltxPath returns the full path to an LTX file.\nfunc (c *ReplicaClient) ltxPath(level int, filename string) string {\n\treturn c.Path + \"/\" + fmt.Sprintf(\"%04x/%s\", level, filename)\n}\n\n// fileIterator represents an iterator over LTX files in OSS.\ntype fileIterator struct {\n\tctx    context.Context","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/oss/replica_client.go#L359-L395","documentation":"After listing all objects, DeleteAll deletes them in batches via DeleteMultipleObjects. A batch-level API failure is wrapped with the batch size. Like error 385 but scoped to the full-bucket delete path; per-object errors are surfaced by deleteResultError instead.","triggerScenarios":"DeleteAll's deletion loop hitting AccessDenied, NoSuchBucket, throttling (SlowDown), or network failure when submitting a batch of n object keys.","commonSituations":"Deleting a very large number of LTX files and hitting OSS batch-delete rate limits; missing DeleteObjects permission; bucket state changed concurrently.","solutions":["Grant oss:DeleteObjects permission to the RAM role.","If throttled (SlowDown in wrapped error), retry with backoff or delete during low-traffic periods.","Confirm the bucket exists and the region/endpoint are correct.","Re-run the operation; batch deletes are idempotent for already-deleted keys."],"exampleFix":"// before (RAM policy)\n{\"Effect\":\"Allow\",\"Action\":[\"oss:ListObjects\",\"oss:GetObject\"],\"Resource\":\"acs:oss:*:*:my-bucket/*\"}\n// after\n{\"Effect\":\"Allow\",\"Action\":[\"oss:ListObjects\",\"oss:GetObject\",\"oss:DeleteObject\",\"oss:DeleteObjects\"],\"Resource\":\"acs:oss:*:*:my-bucket/*\"}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := client.DeleteAll(ctx); err != nil {\n    if strings.Contains(err.Error(), \"SlowDown\") { time.Sleep(time.Minute); return client.DeleteAll(ctx) }\n    return err\n}","preventionTips":["Ensure DeleteObjects permission before bulk cleanup.","Throttle mass deletions; OSS rate-limits large batch deletes.","Remember batch deletes are idempotent — safe to re-run after partial failure."],"tags":["oss","delete","permissions","batch"],"backgroundTag":"permission-denied","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}