pingcap / pingcap/tidb

[storage] S3 multipart writer can complete a partial object after UploadPart fails

Open Beginner friendly
#70,048 1 comment 0 reactions 0 assignees View on GitHub
affects-7.5 affects-8.1 affects-8.5 component/br component/store found-by-ai severity/major type/bug
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Bug Report

> Evidence status: current-source RED and local-fix GREEN are both available. Product-owner triage is pending.

### 1. Minimal reproduce step (Required)

Add a current-source unit test in `pkg/objstore/s3store` using the existing mock S3 API:

1. Create a multipart upload through `s3like.Storage.Create` with `Concurrency: 1`.
2. Make part 1 `UploadPart` succeed and return an ETag.
3. Make part 2 `UploadPart` return `ai-native mock upload part failed`.
4. Call `Close` after `Write` returns the injected error.
5. Record `CompleteMultipartUpload`, `AbortMultipartUpload`, and the close error.

The current-source RED was executed with:

```bash
go test ./pkg/objstore/s3store \
-run TestAINativeS3StorageCreateUploadPartFailureThenCloseRED \
-count=1 -timeout 60s -v
```

Observed:

```text
writeErr=ai-native mock upload part failed
closeErr=
completeCalls=1
completedParts=1
```

### 2. What did you expect to see? (Required)

After any UploadPart failure, Close should not CompleteMultipartUpload; it should abort when possible and preserve the root UploadPart error.

### 3. What did you see instead? (Required)

writeErr is the injected UploadPart error, but closeErr is nil, completeCalls=1 and completedParts=1.

### 4. What is your TiDB version? (Required)

current master 13282a8

Likely root cause and fix direction

multipartWriter.Write returns UploadPart error but does not store failed state; multipartWriter.Close always completes accumulated completeParts.

Contributor guide

Open the contributing guide

Research direction

Start in pkg/objstore/s3store with multipartWriter.Write and Close, then run the named RED test using the existing mock S3 API. Verify that an UploadPart failure is retained, Close avoids CompleteMultipartUpload, aborts when possible, and preserves the root upload error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, go
Domain
backend, cloud
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.