Skip to content

[BUG] Cosmos P2: Lease cleanup endlessly retries already-absent items #51137

Open

Description

Describe the bug
Alan Zimmer's November 6, 2026 audit of com.azure:azure-cosmos:4.84.0-beta.1 reports that both PK and EPK lease cleanup implementations assign effectiveSubStatusCode using getStatusCode() rather than getSubStatusCode(). A normal per-item 404/0 bulk-delete response is therefore interpreted as 404/404, never removed from the pending set, and repeatedly deleted. This can hang migration startup and issue unnecessary requests. Reported priority: P2.

Exception or Stack Trace
No stack trace supplied. Relevant response: non-null per-item status/substatus 404/0.

To Reproduce
Have lease cleanup receive a non-null 404/0 bulk-delete response for an already-absent lease. Check whether the item leaves the pending set and cleanup completes after one delete call. Cover both PK and EPK implementations. This is a proposed regression scenario, not a runtime reproduction from the audit.

Code Snippet
Not supplied. Reported locations: PK LeaseStoreManagerImpl.java:258-275 and EPK LeaseStoreManagerImpl.java:262-279 in the audited source.

Expected behavior
An already-absent lease with 404/0 is treated as successfully cleaned up; processing terminates rather than retrying indefinitely.

Screenshots
N/A.

Setup (please complete the following information):

  • OS: Not reported.
  • IDE: Not reported.
  • Library/Libraries: com.azure:azure-cosmos:4.84.0-beta.1.
  • Java version: Not reported.
  • App Server/Environment: Change Feed Processor lease cleanup during migration; PK and EPK implementations.
  • Frameworks: Not reported.

Dependency mismatch: Not indicated; dependency tree/logs were not supplied.

Additional context
Proposed fix from the audit: use getSubStatusCode() when assigning effectiveSubStatusCode in both copies.

Regression coverage: verify that a non-null 404/0 response completes cleanup after exactly one delete call in each implementation.

Evidence: Alan source-traced this finding through callers and recovery paths; it was not runtime-reproduced. No live Cosmos calls or full SDK test suite were run, and no repository files were changed. This issue tracks validation and implementation of the proposed fix, not an already-applied fix.

Information Checklist

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ClientThis issue points to a problem in the data-plane of the library.Cosmos

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions