apache / apache/kyuubi

[Bug] REST API GET /batches/{batchId} return inconsistent

Open
#4,409 7 comments 0 reactions 0 assignees View on GitHub
kind:bug priority:major
Dominant language
Scala
Stars
2.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [X] I agree to follow this project's [Code of Conduct](https://www.apache.org/foundation/policies/conduct)

### Search before asking

- [X] I have searched in the [issues](https://github.com/apache/kyuubi/issues?q=is%3Aissue) and found no similar issues.

### Describe the bug

Deployed two kyuubi servers, provide a unified external rest api through load balancing.

I submitted a batch task and got the task status through `/api/v1/batches/{batchId}` polling.

From the log below, all requests are sent to a kyuubi server with same ip:
`2023-02-24 16:14:23.726 status=200, the normal request, jobState is running`
`2023-02-24 16:15:01.045 Invalid batchId`
`2023-02-24 16:15:01.046 status=404, the abnormal request`
`2023-02-24 16:18:14.848 status=200, the normal request, jobState is finished`

Repeated testing found that this phenomenon occurs at the end of the job.

```java
2023-02-24 16:14:23.726 INFO org.apache.kyuubi.server.http.authentication.AuthenticationAuditLogger: user=401(auth:BASIC) ip=xxx.xxx.7.74 proxyIp=null method=GET uri=/api/v1/batches/7c1a4b85-f396-4f79-a2b8-e63348d9c4d7 params=null protocol=HTTP/1.1 status=200
2023-02-24 16:15:01.045 ERROR org.apache.kyuubi.server.api.v1.BatchesResource: Invalid batchId: 7c1a4b85-f396-4f79-a2b8-e63348d9c4d7
2023-02-24 16:15:01.046 INFO org.apache.kyuubi.server.http.authentication.AuthenticationAuditLogger: user=401(auth:BASIC) ip=xxx.xxx.7.74 proxyIp=null method=GET uri=/api/v1/batches/7c1a4b85-f396-4f79-a2b8-e63348d9c4d7 params=null protocol=HTTP/1.1 status=404
2023-02-24 16:15:12.498 INFO org.apache.kyuubi.operation.BatchJobSubmission: Monitoring submitted SPARK batch[7c1a4b85-f396-4f79-a2b8-e63348d9c4d7] job: spark-080f7446308347ab84c1fb81f1713e33
2023-02-24 16:18:14.848 INFO org.apache.kyuubi.server.http.authentication.AuthenticationAuditLogger: user=401(auth:BASIC) ip=xxx.xxx.7.74 proxyIp=null method=GET uri=/api/v1/batches/7c1a4b85-f396-4f79-a2b8-e63348d9c4d7 params=null protocol=HTTP/1.1 status=200
```

### Affects Version(s)

branch-1.7

### Kyuubi Server Log Output

_No response_

### Kyuubi Engine Log Output

_No response_

### Kyuubi Server Configurations

_No response_

### Kyuubi Engine Configurations

_No response_

### Additional context

_No response_

### Are you willing to submit PR?

- [ ] Yes. I would be willing to submit a PR with guidance from the Kyuubi community to fix.
- [ ] No. I cannot submit a PR at this time.

Contributor guide

Open the contributing guide

Research direction

Start at the REST endpoint in org.apache.kyuubi.server.api.v1.BatchesResource and trace the batch lifecycle through org.apache.kyuubi.operation.BatchJobSubmission. Reproduce the polling behavior with two Kyuubi servers and compare the logged 200 and 404 responses near job completion; done means GET /api/v1/batches/{batchId} returns consistent results during that lifecycle.

Written by the indexing model from the issue text.

Assessment

Tech stack
spark
Domain
api, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.