apache/beam · error

GetJobMetrics: unknown jobID: %v

Error message

GetJobMetrics: unknown jobID: %v

What it means

Error returned by the Prism job server's GetJobMetrics gRPC handler when the request's job ID does not match any job known to the server (getJob returned nil). Typically means the job already expired from the store, was submitted to a different Prism instance, or the ID is malformed.

Source

Thrown at sdks/go/pkg/beam/runners/prism/internal/jobservices/management.go:510

			curState = job.stateIdx + 1
			job.streamCond.L.Unlock()
			stream.Send(&jobpb.JobMessagesResponse{
				Response: &jobpb.JobMessagesResponse_StateResponse{
					StateResponse: &jobpb.JobStateEvent{
						State: state,
					},
				},
			})
			job.streamCond.L.Lock()
		}
	}
}

// GetJobMetrics Fetch metrics for a given job.
func (s *Server) GetJobMetrics(ctx context.Context, req *jobpb.GetJobMetricsRequest) (*jobpb.GetJobMetricsResponse, error) {
	j := s.getJob(req.GetJobId())
	if j == nil {
		return nil, fmt.Errorf("GetJobMetrics: unknown jobID: %v", req.GetJobId())
	}
	return &jobpb.GetJobMetricsResponse{
		Metrics: &jobpb.MetricResults{
			Attempted: j.metrics.Results(tentative),
			Committed: j.metrics.Results(committed),
		},
	}, nil
}

// GetJobs returns the set of active jobs and associated metadata.
func (s *Server) GetJobs(context.Context, *jobpb.GetJobsRequest) (*jobpb.GetJobsResponse, error) {
	s.mu.Lock()
	defer s.mu.Unlock()

	resp := &jobpb.GetJobsResponse{}
	for key, job := range s.jobs {
		resp.JobInfo = append(resp.JobInfo, &jobpb.JobInfo{
			JobId:           key,

View on GitHub (pinned to 12126d8942)

Solutions

  1. Use the job ID returned by the current run, not one copied from stale output.
  2. Query metrics while the job still exists on the same server instance.
  3. Confirm you're connected to the prism server that executed the job.
  4. Wrap the call to handle 'unknown jobID' by re-creating or re-running the job.
Defensive patterns

Strategy: try-catch

Validate before calling

if jobID == "" || jobID != runningJobID {
    return errors.New("cannot fetch metrics: unknown job id")
}

Try / catch

resp, err := client.GetJobMetrics(ctx, req)
if err != nil && strings.Contains(err.Error(), "unknown jobID") {
    return nil, fmt.Errorf("job %s no longer available on this server: %w", req.GetJobId(), err)
}

Prevention

When it happens

Trigger: Calling the GetJobMetrics RPC with a GetJobMetricsRequest whose JobId matches no prepared/running job (unknown or expired ID).

Common situations: Polling metrics after job completion once the server dropped it; querying metrics from a different prism instance than the one that ran the job; typo'd job ID from logs.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/931636c9c0b679cb. Report an issue: GitHub.