HDDS-11900. Introduce fine-grained locking for OBS#10683
Draft
spacemonkd wants to merge 1 commit into
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
HDDS-11900. Introduce fine-grained locking for OBS key operations to enable leader-execution model.
Description
This pull request introduces fine-grained key-path-level locking for Ozone Object Store (OBS) key operations as a prerequisite for the leader-execution model (HDDS-11898). Currently, all OBS key operations within a bucket are serialized by a single bucket-level write lock (
BUCKET_LOCK), preventing concurrent operations on different keys. This change enables parallel key operations by introducing a lock hierarchy that allows bucket-level read locks (preventing bucket deletion) paired with per-key write locks.Problem Statement
The leader-execution design requires deterministic, repeated execution of requests: leaders execute request logic and produce a side-effect log, while followers replay the log to apply only the side effects (DB mutations). This model breaks if concurrent mutations on different keys within a bucket are possible—replaying in an arbitrary order risks different outcomes than the leader's execution.
Today's coarse bucket-level write locks serialize all key operations, making determinism straightforward but limiting throughput. The solution is to introduce fine-grained locking: keys within a bucket can be locked independently using striped locks, enabling concurrent operations on different keys while maintaining determinism through ordered multi-key lock acquisition (
bulkGet()).Changes Proposed
Lock Infrastructure:
OzoneLockStrategyinterface with default methods for multi-key locks and bucket-read-only locks, enabling backward-compatible migration of handlers.OBSKeyPathLockStrategy: acquires BUCKET_LOCK read + per-key KEY_PATH_LOCK writes using orderedbulkGet()for multi-key operations; bucket-read-only operations acquire only BUCKET_LOCK read.RegularBucketLockStrategyfallback: preserves BUCKET_LOCK write behavior when key-path locking is disabled (config default:ozone.om.key.path.lock.enabled=false).Request Handler Migrations:
Design & Approach
The implementation follows the OBS locking strategy defined in :
bulkGet()-based ordered lock acquisition to guarantee deadlock-freedom.The migration uses the Strategy pattern (
OzoneLockStrategy) to avoid coupling handlers to specific lock schemes, allowing per-bucket-layout lock selection (OBS vs FSO) and per-config feature gating.References:
@kerneltime's reference specification: https://github.com/kerneltime/ozone/tree/9c59ae0d66227ce10849b4f914f9efdce9318103/hadoop-hdds/docs/content/design/leader-execution
Pre-Ratis Execution design document: #10503
What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-11900
How was this patch tested?
Unit Tests:
TestOBSKeyPathLockStrategy: single-key, multi-key, bucket-read-only lock operations; concurrent lock acquisition on different keys; deadlock-free ordered locking.TestOMKeyRequestandTestS3MultipartRequestbase classes to mockgetOzoneLockProvider().Integration Tests (all passing)
Compilation:
mvn clean install -U -DskipTests -DskipShadeFeature Flag:
ozone.om.key.path.lock.enabled=false(no behavior change; uses RegularBucketLockStrategy).