leizhiyuan opened a new issue, #1460:
URL: https://github.com/apache/rocketmq-clients/issues/1460

   ### Before Creating the Bug Report
   
   - [x] I found a bug, not just asking a question, which should be created in 
[GitHub Discussions](https://github.com/apache/rocketmq-clients/discussions).
   - [x] I have searched the [GitHub 
Issues](https://github.com/apache/rocketmq-clients/issues) and [GitHub 
Discussions](https://github.com/apache/rocketmq-clients/discussions) of this 
repository and believe that this is not a duplicate.
   - [x] I have confirmed that this bug belongs to the current repository, not 
other repositories of RocketMQ.
   
   ### Programming Language of the Client
   
   Rust
   
   ### Runtime Platform Environment
   
   Linux 6.6 x86_64, 32 cores
   
   ### RocketMQ Version of the Client/Server
   
   Client: Rust `rocketmq` 5.0.0, master `e90ece7a`
   Server: mock proxy over real gRPC (see the test environment below)
   
   ### Run or Compiler Version
   
   rustc 1.97.1 (also checked with 1.74.0, the MSRV)
   
   ### Describe the Bug
   
   `SimpleConsumer::ack` (and `LiteSimpleConsumer::ack`) panics with `index out 
of bounds: the len is 0 but the index is 0` when the server answers an ack with 
status OK and an empty `entries` list. `Client::ack_message` returns 
`result[0]` of the response entries 
([client.rs#L787](https://github.com/apache/rocketmq-clients/blob/e90ece7a/rust/src/client.rs#L787)),
 and the only caller discards it.
   
   `entries` is a repeated field, so an empty list is valid on the wire. The 
Apache proxy fills it today (`AckMessageActivity`), but other implementations 
(e.g. a gateway, or a mock server in tests) may not, and the client should not 
crash the calling task on a well-formed response. Java only checks the status 
(`SimpleConsumerImpl#ack0` → `StatusChecker.check(response.getStatus(), ..)`).
   
   Found while building the benchmark for #1445: the first version of the mock 
server returned no entries and every `SimpleConsumer::ack` panicked.
   
   ### Steps to Reproduce
   
   A server that answers `AckMessage` with `status = OK` and no entries; call 
`SimpleConsumer::ack`.
   
   ### What Did You Expect to See?
   
   `Ok(())`, as in Java.
   
   ### What Did You See Instead?
   
   ### Test environment
   
   - Host: Linux 6.6 x86_64, 32 cores; rustc 1.97.1, release build.
   - Client: `master` `e90ece7a` ("before") vs. the PR branch rebased on it 
("after"); nothing else differs.
   - Server: a mock RocketMQ proxy that speaks the real gRPC protocol over TCP 
on 127.0.0.1 (tonic 0.9, `TCP_NODELAY` like grpc-java), driven only through the 
public API of the client. The same harness is used for every number in #1445. 
Each cell: 3 runs of the same binary, median shown (all 3 runs in brackets). 
Absolute numbers depend on the machine and the mock; the before/after ratio is 
the point.
   
   | `SimpleConsumer`, 16 tasks receive(32) + ack each, server returns no 
result entries | before | after |
   |---|---|---|
   | result | the first ack of every task **panics** (`client.rs:787`: index 
out of bounds), the benchmark aborts; 3 of 3 runs | **4,308** msg/s [4317, 
4306, 4308], 0 panics; same as a server that returns entries (4,306) |
   
   ### Additional Context
   
   Not a performance issue, but found by and filed with the Rust performance 
work in #1445.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to