apache / apache/beam

[Bug]: Go Prism Runner Concurrent Map Mutations

Open
#32,656 4 comments 0 reactions 1 assignee Claimed by @waneal View on GitHub
bug go P2
Dominant language
Java
Stars
8.7k
Forks
4.7k
Avg merge
1d 20h
Merged PRs (30d)
196

Description

### What happened?

There are race conditions in the Server of the prism runner's gRPC server in Go. Reads and writes to the [`artifacts` variable within Server](https://github.com/apache/beam/blob/d84cfffd017342542cc1dc3e7ae30452a485e3b1/sdks/go/pkg/beam/runners/prism/internal/jobservices/server.go#L61C2-L61C10) are not protected by a mutex. This means race detection will occasionally crash this logic because it's not thread safe.

Given the nature of this class. It's likely other variables are at risk of races as well.

```
fatal error: concurrent map writes

goroutine 1737 [running]:
github.com/apache/beam/sdks/v2/go/pkg/beam/runners/prism/internal/jobservices.(*Server).ReverseArtifactRetrievalService(0xc0001195c0, {0x29c74a0, 0xc000be4570})
/github/home/go/pkg/mod/github.com/apache/beam/sdks/v2@v2.59.0/go/pkg/beam/runners/prism/internal/jobservices/artifact.go:87 +0x885
github.com/apache/beam/sdks/v2/go/pkg/beam/model/jobmanagement_v1._ArtifactStagingService_ReverseArtifactRetrievalService_Handler({0x2693b80?, 0xc0001195c0}, {0x29c06d0, 0xc000b321e0})
/github/home/go/pkg/mod/github.com/apache/beam/sdks/v2@v2.59.0/go/pkg/beam/model/jobmanagement_v1/beam_artifact_api_grpc.pb.go:272 +0xd8
google.golang.org/grpc.(*Server).processStreamingRPC(0xc000565a00, {0x29bb248, 0xc000b138c0}, {0x29d4640, 0xc000494b60}, 0xc00167a7e0, 0xc000319c80, 0x4ced6a0, 0x0)
/github/home/go/pkg/mod/google.golang.org/grpc@v1.67.1/server.go:1688 +0x1208
google.golang.org/grpc.(*Server).handleStream(0xc000565a00, {0x29d4640, 0xc000494b60}, 0xc00167a7e0)
/github/home/go/pkg/mod/google.golang.org/grpc@v1.67.1/server.go:1809 +0xe3a
google.golang.org/grpc.(*Server).serveStreams.func2.1()
/github/home/go/pkg/mod/google.golang.org/grpc@v1.67.1/server.go:1029 +0x7f
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 1616
/github/home/go/pkg/mod/google.golang.org/grpc@v1.67.1/server.go:1040 +0x125
```

### Issue Priority

Priority: 2 (default / most bugs should be filed as P2)

### Issue Components

- [ ] Component: Python SDK
- [ ] Component: Java SDK
- [X] Component: Go SDK
- [ ] Component: Typescript SDK
- [ ] Component: IO connector
- [ ] Component: Beam YAML
- [ ] Component: Beam examples
- [ ] Component: Beam playground
- [ ] Component: Beam katas
- [ ] Component: Website
- [ ] Component: Infrastructure
- [ ] Component: Spark Runner
- [ ] Component: Flink Runner
- [ ] Component: Samza Runner
- [ ] Component: Twister2 Runner
- [ ] Component: Hazelcast Jet Runner
- [ ] Component: Google Cloud Dataflow Runner

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.