qianye1001 opened a new issue, #10278:
URL: https://github.com/apache/rocketmq/issues/10278

   ### Is Your Feature Request Related to a Problem?
   
   Currently, when `enableProxyAutoRenew` is enabled, the proxy uses a short 
`defaultInvisibleTimeMills` (~60s) to pop messages and then periodically renews 
the invisible time via `changeInvisibleTime` RPC calls to the broker. This 
introduces several problems:
   
   1. **Handle mapping complexity**: Every `changeInvisibleTime` call returns a 
new receipt handle from the broker. The proxy must maintain a mapping from the 
original handle (known to the client) to the latest renewed handle. This adds 
significant memory overhead and concurrency control complexity 
(`ReceiptHandleGroup` with semaphore-based locking).
   
   2. **Proxy crash makes client handles invalid**: Since the proxy pops with a 
short invisible time (~60s), the client receives a short-lived handle. If the 
proxy crashes, the renewed handle (stored only in proxy memory) is lost, and 
the client's original handle has already expired from the broker's perspective. 
The client **cannot** ack through another proxy, leading to **unavoidable 
duplicate consumption**.
   
   3. **Unnecessary network overhead**: The periodic `changeInvisibleTime` 
calls create continuous RPC traffic between proxy and broker for every un-acked 
message, which is wasteful when consumers are simply processing normally.
   
   ### Describe the Solution You'd Like
   
   Add a dynamic switch `enableReceiptHandleRenew` (default `true` for backward 
compatibility) in `ProxyConfig`:
   
   - When `enableReceiptHandleRenew = true`: Behavior remains unchanged (short 
invisible time + periodic renew).
   - When `enableReceiptHandleRenew = false`:
     - The proxy uses the consumer group's `consumeTimeoutMinute` (from 
`SubscriptionGroupConfig`) as the invisible time during pop, instead of the 
short `defaultInvisibleTimeMills`.
     - The proxy **does not** periodically renew handles via 
`changeInvisibleTime`.
     - The proxy still saves handles and monitors client connectivity. When a 
client disconnects, the proxy uses the saved (unchanged) handle to 
nack/changeInvisibleTime, enabling fast message re-delivery.
     - The client's original receipt handle remains valid for the full consume 
timeout duration, so even if the proxy crashes, the client can reconnect to 
another proxy and ack successfully.
   
   This approach preserves fast crash recovery for client failures (proxy 
detects disconnect and nacks) while also being resilient to proxy failures 
(client handle stays valid).
   
   ### Describe Alternatives You've Considered
   
   1. **Keep the current renew mechanism as-is**: This works but has the 
drawbacks described above — particularly the proxy-crash scenario where client 
handles become invalid.
   
   2. **Persist renewed handles to external storage (e.g., Redis)**: This would 
survive proxy crashes but adds infrastructure dependency and latency. The 
proposed solution achieves the same resilience without any external dependency.
   
   3. **Use a fixed long invisible time without saving handles**: This would 
lose the ability to nack on client disconnect, meaning client crashes would 
require waiting for the full invisible time to expire before re-delivery.
   
   ### Additional Context
   
   **Failure scenario comparison:**
   
   | Scenario | Current (renew=true) | Proposed (renew=false) |
   |----------|---------------------|----------------------|
   | Client crash, proxy alive | Proxy stops renewing → ~1min recovery | Proxy 
nacks → fast recovery |
   | Proxy crash, client alive | Client's short-lived handle expired, renewed 
handle lost → **duplicate consumption** | Client's handle still valid → **ack 
succeeds via another proxy** |
   | Both crash | ~1min recovery (short invisible time) | Wait for 
consumeTimeout (configurable, e.g. 15min) |
   
   The probability of simultaneous proxy + client failure is low, making the 
proposed approach a better trade-off for most production scenarios.
   


-- 
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