Skip to content

HDDS-15330. Implement FCR lease mechanism - #11905

Open
ivandika3 wants to merge 40 commits into
apache:masterfrom
ivandika3:HDDS-15330
Open

ivandika3 wants to merge 40 commits into
apache:masterfrom
ivandika3:HDDS-15330

Conversation

@ivandika3

@ivandika3 ivandika3 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This patch introduces the FCR lease mechanism similar to HDFS block report lease mechanism to bound the memory overhead of SCM due to concurrent full container reports. See https://issues.apache.org/jira/browse/HDDS-15330 for the background issues.

Overall flow

  1. A datanode marks its FCR pending / deferred and requests a lease through a normal heartbeat with a request heartbeat with empty container report and fullContainerReportDeferred set.
  2. SCM grants a nonzero lease ID and term if eligible and capacity is available
    1. ozone.scm.max.full.container.report.leases is the maximum number of concurrent FCR that SCM allows at one time. It acts as the rate limit
  3. The datanode immediately sends a follow-up heartbeat containing the FCR and the FCR lease.
  4. SCM validates the lease, then queues and processes the report
  5. Completion or discard release the lease and allow new FCR to be handled.

If no lease is granted, the datanode retries on subsequent heartbeats. Other reports and commands continue normally.

Lease Lifecycle

The following is the lease lifecycleYou can refer to the SCMFullContainerReportLeaseManager (state is in LeaseState).

The main flow is as follow

NO LEASE
    |
    | Lease request granted: reserve capacity
    v
 GRANTED
    |
    | Valid leased FCR received: claimLease()
    v
 CLAIMED
    |
    | Report handler starts: startProcessing()
    v
PROCESSING
    |
    | Processing succeeds or fails: complete(processed)
    v
NO LEASE

However, there are also other transitions (e.g. lease expiry, replacement request, new registration, etc).

GRANTED --[replacement request granted; new lease ID]--> GRANTED

GRANTED --[grant expiry detected]----------------------> NO LEASE
GRANTED --[lease request prunes grants from other terms]> NO LEASE
GRANTED --[new deferred registration]------------------> NO LEASE
GRANTED --[datanode removed from SCM]------------------> NO LEASE

CLAIMED --[dispatch rejected or publication fails]-----> NO LEASE
CLAIMED --[queued report discarded or queue cleared]---> NO LEASE

Notable properties

  • GRANTED, CLAIMED, and PROCESSING all reserve capacity
    • CLAIMED will be invoked before it's queued in the EventQueue to be processed
  • Only GRANTED expires since once it goes to CLAIMED and PROCESSING, the FCR has been received and should be completely handled by SCM (not waiting for datanode).
  • Expiry is checked during lease requests or report validation, not by a timer.
    • This is to simplify the logic. Having a thread to expire the leases would need more bookkeepings. The number of leases should not be too large so we can afford outstanding leases and we can allow lease operation to expire the existing leases.

SCM HA

The FCR lease is not replicated through Raft and the lease ID is not generated using the SCM HA sequence ID generator. This is because container report (FCR and ICR) processing is handled by both the SCM leader and followers. Therefore, we only need that the lease ID for each SCM node to be different.

Cross Cutting Concerns

  • Feature flag
    • ozone.scm.fullcontainer.report.rate.limit.enabled flag is introduced with default disabled. This would allow us to revert
      back to accepting all FCR report if for example it causes SCM to be in SafeMode longer than necessary.
    • ozone.scm.fullcontainer.report.rate.limit.enabled is reconfigurable per SCM node. This allows us to evaluate the FCR lease mechanism and disable it quickly if there are issues.
  • Compatibility: This patch should allow rolling upgrade
    • New SCM and old datanode: Old datanode immediately sends FCR. In that case, SCM would bypass the lease mechanism and handle the container report immediately.
    • Old SCM and new datanode: The datanode would be able to check whether SCM supports the FCR lease through HddsVersion.FULL_CONTAINER_REPORT_LEASE in the software version.

Evaluations

There are tradeoffs on enabling the FCR lease mechanism

Advantages

  • The number of FCR that can exist in SCM (RPC queue, Event queue, processing) is bounded by ozone.scm.max.full.container.report.leases
    • Therefore in a cluster with a lot of dense nodes or a lot of small containers, this would reduce the memory requirement of SCM (cost saving) and allow more stable SCM (less JVM pressure from container reports)

Disadvantages

  • SafeMode requires that a certain number of containers are going to be recorded. The FCR lease mechanism can increase the time it takes for SCM to exit SafeMode.
    • We can either reduce the heartbeat interval or increase the FCR lease limit for this, or disable the feature flag if it's too long
  • There is an extra one RTT for normal heartbeat even if lease is disabled in SCM
    • The datanode will first send an empty FCR with the deferred flag true and only send the actual FCR once SCM grants the lease or FCR lease is disabled.
  • Heartbeats processing might be delayed indefinitely (starvation). There is not fairness guarantee for the FCR lease so technically it is possible for a single datanode heartbeat to get rejected since it cannot get the lease. The fairness improvement can be handled in future patch.
    • HDFS block lease mechanism also doesn't have the fairness guarantee and seems there are no reported issues, so it might be ok for now.
    • It might be possible that we can have implementation so that SCM prioritize DN that have gone longest without successfully processed FCR. Also we might also make the DNs that has their first registration FCR to receive a special priority.

Generated-by: GPT 6.1 Sol

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/HDDS-15330

How was this patch tested?

UT, IT. (Clean CI: https://github.com/ivandika3/ozone/actions/runs/41396339409)

Retain accepted FCR leases until processing or discard and preserve heartbeats and ICRs across snapshot failures and lease waits.

Use compact container IDs for safe-mode registration events, remove the test-only lease-count accessor, and add regression and integration coverage.
Mark deferred registration reports ready without generating a snapshot, and send one bounded follow-up heartbeat within the granting endpoint task.

Cover re-registration readiness, lease denial, and blocked SCM peers; validate delivery with a heartbeat interval longer than the lease duration.
Use capacity-based lease grants, raise the default outstanding lease limit to 10, and cover startup safe-mode progress. Keep endpoint task scheduling changes in HDDS-15330-EXT.
Remove the SCM endpoint test's direct HDFS reference by using Mockito's default mock answer, and restore the missing SCMContext import in TestStorageContainerManager.

Validated with 19 endpoint tests, SCM dependency analysis, full PMD including integration-test compilation, and repository-wide checkstyle.
Keep capability negotiation independent of finalization and activate leased reporting without re-registration. Preserve FCR/ICR ordering and retry readiness across finalization, with unit and integration coverage.
Preserve captured datanode version rejections before FCR deferral checks, including during concurrent SCM finalization. Shorten the test follower's election timeout without weakening removal shutdown assertions.
…ssion

Emit the node registration event on successful registration while retaining container-based SafeMode checks after FCR processing. Clarify pending FCR and leased report naming, and remove the test-only dispatcher overload.
Prepare accepted leased and legacy reports in the protocol server and make them authoritative for dispatch. Keep unpublished-report cleanup local to the dispatcher, removing heartbeat cloning and payload dispatch flags.
Replace the processing lifecycle interface and unrestricted implementation with an optional LeaseClaim held directly by each FCR. Preserve idempotent completion and use real lease claims in tests. Rename the datanode removal handler to callback and document its locking contract.
Make grant, claim and processing states explicit while preserving capacity and expiry behavior. Show leased and unleased heartbeat paths directly, derive registration status from claims, and centralize documented SCM eligibility policy. Document registration generations, completion and SafeMode milestones, with regression coverage for re-registration and SCM modes.
@ivandika3 ivandika3 self-assigned this Nov 2, 2026
Keep leases local to each SCM and preserve outstanding grants across leadership changes. Remove lease-term protocol and validation logic while retaining command terms, readiness checks, expiry, and capacity accounting.

Verified with 270 focused tests, three FCR integration tests, and Checkstyle.
…isement

Rely on apparent-version activation and ZDU registration fencing instead of a separate SCM capability flag. Preserve Recon reporting and pre-finalization fresh FCR generation and ICR handling.

Verified with 324 focused tests, three FCR integration tests, and Checkstyle.
@ivandika3 ivandika3 changed the title HDDS-15330. Implement SCM FCR lease mechanism for FCR rate limit HDDS-15330. Implement SCM FCR lease mechanism Nov 2, 2026
@ivandika3 ivandika3 changed the title HDDS-15330. Implement SCM FCR lease mechanism HDDS-15330. Implement FCR lease mechanism Nov 2, 2026
@ivandika3
ivandika3 marked this pull request as ready for review November 2, 2026 08:40
@ivandika3
ivandika3 requested a review from sumitagrawl November 3, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant