# rpc 错误：代码 = DataLoss 描述 = 消息校验和不匹配

- **ID:** `go/grpc-data-loss-corruption`
- **领域:** go
- **类别:** network_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

gRPC 消息在传输过程中损坏，导致校验和验证失败。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 1.56.x | active | — | — |
| 1.57.x | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   creds := credentials.NewClientTLSFromCert(certPool, ""); conn, err := grpc.Dial(address, grpc.WithTransportCredentials(creds))
   ```
2. **** (90% 成功率)
   ```
   req := &pb.Request{Data: data, Checksum: sha256.Sum256(data)}; server verifies checksum
   ```
3. **** (85% 成功率)
   ```
   backoff := grpc.Backoff{MaxDelay: 5 * time.Second}; conn, err := grpc.Dial(address, grpc.WithConnectParams(grpc.ConnectParams{Backoff: backoff}))
   ```

## 无效尝试

- **Retrying the same request without checks.** — Corruption may be transient but same data may fail again. (70% 失败率)
- **Turning off checksum checking.** — Data integrity risk. (80% 失败率)
- **Blaming server for incorrect checksum.** — Network issues are common cause. (50% 失败率)
