Commit Graph

787 Commits

Author SHA1 Message Date
Shelron 036075ccfa
[Bugfix]: route cache allocator capacity adapt (#1958)
* fix: route cache allocator capacity

* type cast
2026-04-23 12:50:19 +08:00
skygragon aad5111781
[Store] Support degraded startup when master is unavailable (#1930)
* [Store] Support degraded startup when master is unavailable

Problem:
P2P client startup fails when master is unavailable, blocking the
entire application. This is problematic for scenarios where the
client should be able to start independently and wait for master
to become available.

Solution:
1. Refactor P2PClientService::Init to support degraded startup:
   - Try ConnectToMaster/RegisterClient, allow failure
   - Set HA state to FULL or DEGRADED based on connection result
   - Skip MountSegment in degraded mode
   - Heartbeat thread will recover when master becomes available

2. Optimize initialization order:
   - ConnectToMaster/RegisterClient first
   - StartHeartbeat before InitTransferEngine (faster heartbeat)
   - InitTransferEngine and InitStorage after heartbeat starts

3. Add HARecoveryManager::SetState() for setting initial state

4. Make connection_interrupted_ atomic for thread-safe access

Changes:
- ha_recovery_manager.h: Add SetState() method
- client_service.h/cpp: Support degraded startup in heartbeat logic
- p2p_client_service.cpp: Refactor Init flow with degraded support

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

* [Store] Refactor HA recovery manager and client service

1. Remove unused master_server_entry parameter from ReconnectToMaster.
   In non-HA mode, current_master_address is already initialized to
   master_server_entry, making the parameter redundant.

2. Replace SetState() with constructor initial_state parameter.
   SetState() bypasses the state machine transition logic, which breaks
   encapsulation. Initial state should only be set during construction.

3. Add WaitForReady() to encapsulate initialization wait logic.
   Extracts the ready_for_recovery_ and data_manager_ check into a
   separate method for better readability in RecoveryPipelineMain.

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

* [Store] Add TODO comment for race window in segment mount logic

Add documentation explaining the race condition between IsDegraded()
check and MountSegment() call, and outline future improvement plan
to decouple storage layer initialization from master interaction.

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

---------

Co-authored-by: wl177541 <wl177541@antgroup.com>
Co-authored-by: Claude (antchat/GLM-5) <noreply@anthropic.com>
2026-04-22 20:56:56 +08:00
Wan 188bb41121
[Store] Remove read pool and slot of stress test (#1955)
* remove read pool and fix typo

* add parameter check

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-22 19:09:51 +08:00
Wan 29e2c7e873
[Store] optimize stress test (#1953)
Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-22 16:32:01 +08:00
Wan 0d96064ee0
[Store] Optimize batch_put with BatchGetWriteRoute RPC (#1947)
* fix write route

* optimize batch_put by adding batch_get_write_route rpc in master

* fix code format

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-21 22:28:25 +08:00
skygragon b21f90d032
[Store] Add HTTP metrics endpoint for Client (#1934)
* [Store] Add HTTP metrics endpoint for Client

Add HTTP server to expose client metrics via Prometheus-compatible endpoints.
This brings Client metrics exposure in line with Master's implementation.

Changes:
- Add metrics_port (default: 9003) and enable_metrics_http config options
- Add coro_http_server in ClientService for metrics HTTP endpoints
- Expose /metrics, /metrics/summary, and /health endpoints
- Add GetMetricsPort() and IsMetricsHttpEnabled() API methods
- Fix port type from int16_t to uint16_t to avoid overflow for ports > 32767
- Add unit tests for config builder and metrics settings
- Fix parameter passing in HA integration test

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

* [Client] Fix invalid return value in StartMetricsHttpServer

Return 0 instead of -1 on failure, since the function returns uint16_t.
-1 would be implicitly converted to 65535, which is a valid port number
and could cause confusion.

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

* [Client] Add HA state to health endpoint

Add GetHealthStatus() virtual method to ClientService, returning "OK"
by default. P2PClientService overrides it to return the current HA
state (FULL/DEGRADED/SYNCING) via HARecoveryManager.

Also add toString(HAClientState) helper in types.h for consistent
string conversion.

Co-Authored-By: Claude (antchat/GLM-5) <noreply@anthropic.com>

---------

Co-authored-by: wl177541 <wl177541@antgroup.com>
Co-authored-by: Claude (antchat/GLM-5) <noreply@anthropic.com>
2026-04-21 17:35:20 +08:00
Wan 90f2005b55
[Store] Parallelize Local and Remote Read/Write in Batch Scenarios (#1921)
* tmp commit

* optimize

* fix tests

* tmp commi

* refactor: decouple async memcpy execution into a dedicated TaskHandle-based architecture and remove legacy executor from P2PClientService

* refactor: implement RouteIterator for async read retries and add WriteRetryContinuation for non-blocking remote writes

* optimize format and add ScopedVLogTimer

* optimize stress workload test

* fix some details

* remove async memcpy queue length

* fix compile

* optimize stree workload runner example

* fix format

* fix ha integration test

* fix memory leak when te failed

* Asynchronize the master route query in the retry chain of data reading and writing

* Unify the definition of BatchID

* fix ha test bug for async route sync with master

---------

Co-authored-by: “JiaQi <2963103258@qq.com>
Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-20 11:47:43 +08:00
skygragon 6fd613e370
[CI] Improve code format check to only scan changed files (#1922)
Cherry-picked from main branch commits:
- 30ca086 [CI] Improve Code Formatting Workflow (#1368)
- 0267e35 [CI] chore: update clang-format to v20.1.8 and enforce version 20 (#1379)
- e9f2887 [Misc] Fix silent failure in `code_format.sh` when clang-format is missing (#1824)

Why partial cherry-pick:
The original commits include changes to .github/workflows/ci.yml that conflict
with P2P-Mooncake-Store branch (which has additional changes like Ninja build
support, branch name modifications, etc.). Instead of resolving complex merge
conflicts, we manually applied the following changes:

Files changed:
1. scripts/code_format.sh (new) - script for incremental format checking
2. .github/workflows/ci.yml - clang-format job updated to use the script
3. .github/pull_request_template.md - added format checklist item
4. .pre-commit-config.yaml - clang-format v19.1.0 -> v20.1.8

Benefits:
- Reduces CI time by only checking changed files instead of all 500+ files
- Supports --check mode for CI and --all mode for local full scan
- Properly handles PR vs push events with correct base ref detection

Co-authored-by: wl177541 <wl177541@antgroup.com>
2026-04-17 23:04:04 +08:00
skygragon b0214baf0e
[Test] Fix HA integration test flakiness (#1916)
1. MasterRestartRecovery: Add retry logic for client2 reconnection
   - Each client has its own connection pool, so both need to clear stale
     connections independently after master restart
   - Previously client1 had 10 retries but client2 only tried once

2. ForceRecover: Add re-registration on recovery failure
   - If master restarted and lost client registration, recovery would fail
     with CLIENT_NOT_FOUND error and get stuck in SYNCING state
   - Now retries with re-registration if stuck in SYNCING state

Co-authored-by: wl177541 <wl177541@antgroup.com>
Co-authored-by: Claude (antchat/GLM-5) <noreply@anthropic.com>
2026-04-17 18:10:06 +08:00
skygragon 84a823b9eb
[Build] Add memory-aware compile/link parallelism with Ninja support (#1909)
Cherry-picked from main branch commit 79266ffb4d.
Due to significant branch divergence, not all changes were cherry-picked:
- CI workflow files (ci.yml, ci_cu13.yml) were manually adapted
- Dockerfile and ci_ascend.yml were skipped (not present in this branch)

- Add limit_jobs.cmake module for memory-aware build parallelism
- Auto-detect available memory and CPU cores to calculate safe job limits
- With Ninja, create separate job pools for compilation (~1.5GB/job) and linking (~4GB/job)
- Switch CI workflows to use Ninja generator
- Add ninja-build to dependencies.sh

This helps prevent OOM during linking on high-core machines.

Co-authored-by: wl177541 <wl177541@antgroup.com>
Co-authored-by: Claude (antchat/GLM-5) <noreply@anthropic.com>
2026-04-17 10:52:14 +08:00
Wan 6ab0016ed3
[Store ]Implement Master HA recovery based on client (#1876)
* adjust hearbeat init order

* base version

* add test file

* optimize async metadata notifier and test

* rename master_reachable to master_reconnected for clarity

* rewrite HA integration test: two clients, manual heartbeat, fault scenarios

* refactor ha recovery manager test and fix bugs

* modify the comment

* clang format

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-13 19:33:23 +08:00
Wan 5f2a814eb9
[Store] Implement Async Metadata Notifier for P2P Route Sync (#1875) 2026-04-13 02:34:59 +08:00
Yufeng He 9cd7a12bcc
[Store] Fix P2PClientService::Put silently swallowing write errors (#1825)
* fix: propagate PutViaRoute error in P2PClientService::Put

Put() logged errors from PutViaRoute but always returned success (empty
expected), causing callers to believe the write succeeded when the
underlying route write actually failed with SEGMENT_NOT_FOUND or
NO_AVAILABLE_HANDLE.

Return the error for non-idempotent failures while still treating
REPLICA_NUM_EXCEEDED / REPLICA_ALREADY_EXISTS as success (object already
stored).

Fixes #1817

* fix: also capture remote write errors in PutViaRoute result

Address review feedback from Gemini Code Assist:

1. PutViaRoute: assign write_result error to result before continue
   in the remote write path. Previously, if all remote candidates
   failed, result stayed default-initialized (success) because only
   local write failures were captured.

2. Put: simplify return to use result directly instead of
   re-wrapping with tl::unexpected.
2026-04-07 11:43:43 +08:00
Wan 99fb4d4af6
[Store][Bugfix] Fixed the problem of filling in the wrong TE endpoint
Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-06 22:46:42 +08:00
Wan 0d8a51f417
[Store] Implement Lock-Free P2P Route Cache (#1793)
* 1. implement route cache
2. optimize some concurrency static check

* remove force parameter

* add EBR mechanism

* fix format

* fix: remove incorrect thread safety annotation

* remove useless test

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-04-02 14:46:37 +08:00
Wan 46206e777e
[Store] Add orchestration script for matrix sweeps of stress_workload_test and Optimize client read path of P2P Structure (#1779)
* optimize stress workload test

* optimize p2p read path

* fix ci:
1. fix allocate buffer when read failed in get tensor
2. fix format

* trim slice

* update Get and BatchGet interfaces to accept raw buffer pointers and sizes instead of Slice objects

* fix format

* [PG] Remove CPU-only backend tests from CI (#1628)

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
Co-authored-by: Xun Sun <UNIDY2002@outlook.com>
2026-04-01 17:13:26 +08:00
Wan 4aa6209f8f
[Store] Add ut for P2P-Mooncake-Store (#1715)
* 1. add heartbeat intergration test
2. add QueryClientStatus and GetClientSegment interface in master service

* 1. add client manager test
2. add SyncSegmentMetaResult

* add client_meta test

* add segment manager test

* add concurrency ut for storage tier
2026-03-23 15:08:13 +08:00
EkiRui 62ef96e53b
[Store] Make tiered scheduler incremental and harden SSD tier space management (#1675)
* [Store] Make tiered scheduler incremental

Rework the tiered backend scheduler to avoid a shared global stats lock
and full keyspace scans in the background loop.

Key changes:
- shard stats collection and maintain ordered incremental indexes for
  Simple and LRU snapshots
- split recent heat and recency rank semantics in the scheduler policy
  interface
- build policy input from snapshot candidates plus fast-tier residents
  using scheduler-side metadata cache
- hook scheduler cache maintenance into TieredBackend commit/delete paths
- extend integration tests for concurrent stats, bounded snapshots, and
  wall-clock decay behavior

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Make bucket file eviction async

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Guard bucket offload with physical space

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Unify SSD backend space management

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Preallocate storage tier staging pool

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Make allocation handles own tier lifetime

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Add reclaim planner to tiered scheduler

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Unify tiered backend test init

Fold repeated TieredBackend::Init test setup into a shared helper and guard storage-tier bucket eviction with a safe runtime cast so file-per-key tests no longer crash when capacity is exceeded.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Surface scheduler policy errors

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Fix tensor API CI mode selection

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Fix bucket offload pre-init capacity check

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Fix storage path build warnings

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Unify tiered storage accounting semantics

Clarify storage-tier live-byte accounting versus backend physical-byte accounting, reclaim per-key physical bytes on delete, and make per-key metadata scans idempotent without holding the accounting lock across the full directory walk.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Shard scheduler key cache and surface alloc errors

Shard the scheduler key cache to reduce lock contention, preserve allocation error codes across tier fallback, and tighten storage-tier tests around explicit overflow and capacity failures.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

---------

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>
2026-03-23 14:01:24 +08:00
Wan 5e746c1f01
[Store] Implement the client service and add adaptation to the P2P architecture for the interface on the client side (#1631)
* 1. update client name to client service
2. clang format

* 1. implement ClientConfig for build client service
2. split client service based on architecture

* 1. add graceful shutdown mechanism for store components
2. fix some ut bugs about param or return value type
3. fix signal ignore in seperatly deployment mode

* modify stress workload test to adapt p2p mode

* 1. rename some class and add some comment
2. move dummy_client_monitor start logic to real_client and add stop logic for it

* add in-flight request check

* 1. optimize GetLocal() function
2. rename some var and refactor some code format

* add stream output for replica descriptor

* fix ut bug

* replace dynamic_cast with static_cast

* fix typo

* fix format

* fix ci

* 1. fix error code typo of p2p ut
2. fix destory bug of centralized client service

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-03-17 16:17:35 +08:00
EkiRui f036f3d266
[Store] Add SSD tier support with LRU scheduler and thread-safe implementation (#1493)
* [Store]: Add ssd tier support

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store]: add client scheduler support

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store]: Add CAS support for tiered backend

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Add LRU policy and enhance stats collector

- Add LRUPolicy: watermark-based promotion and eviction
  - Promotion limited by capacity budget (up to low_watermark)
  - Eviction triggered when usage exceeds high_watermark
  - Support EVICT (delete replica) and MIGRATE (move to slow tier)

- Add LRUStatsCollector: maintains LRU ordered key list
  - O(1) access recording using list + hashmap
  - MRU keys at front, LRU keys at back

- Enhance StatsCollector interface:
  - Add RemoveKey() for cleanup on key deletion
  - Add decay factor to SimpleStatsCollector (default 0.5)
  - Prevents history loss between scheduler cycles

- Add size_bytes field to KeyContext for capacity calculations

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Integrate LRU scheduler with TieredBackend

- ClientScheduler enhancements:
  - Support JSON config for policy selection (SIMPLE/LRU)
  - Add OnDelete() callback for LRU list cleanup
  - Implement two-phase action execution (EVICT first, then MIGRATE)
  - Handle NO_AVAILABLE_HANDLE error for insufficient space

- TieredBackend integration:
  - Pass config to ClientScheduler constructor
  - Add OnAccess() call in Commit()
  - Add OnDelete() call in Delete()
  - Add capacity pre-check in Transfer()

- Add integration tests:
  - TestLRUCacheThrashing: end-to-end hot/cold data handling
  - TestLRUPromotionBudget: verify capacity-limited promotion
  - TestLRUEviction: verify cold data eviction

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Improve StorageTier capacity tracking and thread safety

- Add capacity parameter to StorageTier constructor
- GetCapacity() now uses configured capacity or falls back to storage backend config
- Add persisted_size_ tracking for data written to disk
- GetUsage() returns pending_batch_size_ + persisted_size_
- Make pending_batch_size_ atomic for thread-safe GetUsage()
- Add IsPersisted() method to StorageBuffer
- Free() now properly updates persisted_size_ when freeing persisted data

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Reorganize tier files into tiers/ subdirectory

- Move all tier-related files to tiered_cache/tiers/ subdirectory:
  - cache_tier.h (base class)
  - dram_tier.h/cpp
  - storage_tier.h/cpp
  - ascend_tier.h/cpp

- Merge disk_buffer.h into storage_tier.h (StorageBuffer class)

- Update all include paths to use new tiers/ location

- Update CMakeLists.txt for new file locations

This improves code organization by grouping all tier implementations
in a dedicated subdirectory.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Make StorageBuffer::is_on_disk_ atomic for thread safety

Change is_on_disk_ from plain bool to std::atomic<bool> with proper
memory ordering (acquire/release) to prevent data races between
Persist() and concurrent read operations like ReadTo().

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Refactor LRU policy to use global heat ranking

Redesign LRU scheduling algorithm:
- Sort all keys by heat score globally (not per-tier)
- Select hottest keys to fill fast tier up to low_watermark (70%)
- Generate evict/promote actions by comparing current vs target state

This ensures fast tier always contains the globally hottest keys,
and usage stabilizes at low_watermark after scheduling.

Update tests to verify:
- All hot keys are retained in DRAM
- Total keys in DRAM matches expected slots
- Cold keys only fill remaining slots after hot keys

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Fix use-after-free in StorageTier::FlushInternal

Add is_flushing_ flag to StorageBuffer to prevent Free() from
destroying a buffer while FlushInternal() is using it.

Race condition fixed:
1. FlushInternal() snapshots buffers and clears pending_batch_
2. FlushInternal() unlocks and starts IO
3. Free() called - buffer not in pending_batch_, not yet persisted
4. Free() destroys buffer -> FlushInternal() crashes on Persist()

Fix:
- FlushInternal() sets is_flushing_=true before unlock
- Free() calls WaitForFlushComplete() to wait for flush
- FlushInternal() sets is_flushing_=false after Persist()

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Fix data race in StorageBuffer between Persist and ReadTo

Add data_mutex_ to protect data_ vector access. Without this lock,
Persist() and ReadTo() can race:
- ReadTo() checks is_on_disk_=false, starts reading data_
- Persist() clears data_ and sets is_on_disk_=true
- ReadTo() accesses cleared data_ -> undefined behavior

The TieredBackend per-key lock doesn't prevent this because
FlushInternal() operates at StorageTier level without acquiring
TieredBackend locks.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] fix UAF race, CAS ordering, flush recovery, copier TOCTOU

- StorageTier: replace spin-wait WaitForFlushComplete with
  condition_variable under batch_mutex_, eliminating the TOCTOU
  window between Free() and FlushInternal()
- StorageTier: FlushInternal restores pending_batch_ on IO failure
  instead of silently dropping entries
- TieredBackend::Commit: validate CAS version before tier->Commit()
  and metadata_sync_callback() to prevent side effects on stale writes,
  with re-check under entry write lock for concurrent race safety
- TieredBackend::Get: remove redundant out_version write
- DRAM->NVME copier: snapshot dst.buffer->data() once to avoid
  TOCTOU with concurrent Persist()
- Add regression tests: CASFailureNoSideEffects,
  CASFailureNoCallbackInvoked, ConcurrentFlushDeleteStress

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Add sync eviction mode and strict allocation with single-tier support

Implement configurable eviction modes (SYNC/ASYNC) and strict allocation
parameter to trigger immediate eviction on allocation failure. Fix single-tier
configuration to properly evict keys via DELETE action when no slow tier exists.

Key changes:
- Add EvictionMode enum (SYNC/ASYNC) to ClientScheduler with JSON config support
- Add strict parameter to TieredBackend::Allocate for tier-specific allocation
- Implement TriggerSyncEviction to immediately free space on allocation failure
- Fix LRU policy to generate DELETE actions for single-tier eviction scenarios
- Add comprehensive tests for capacity limits, sync eviction, and single-tier setup

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Add bucket-level eviction with fragmentation tracking

Implement bucket eviction functionality to reclaim space from fragmented
or old buckets in the storage tier. The eviction strategy prioritizes
buckets with >50% fragmentation, falling back to LRU for non-fragmented
buckets.

Key changes:
- Add SelectBucketForEviction() and EvictBucket() methods to BucketStorageBackend
- Track valid key count per bucket for fragmentation calculation
- Implement MarkKeyDeleted() to update fragmentation metrics on key deletion
- Add TriggerBucketEviction() to StorageTier for manual eviction
- Move Storage Tier tests to dedicated storage_tier_test.cpp file
- Add BucketEviction test to verify eviction functionality

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

* [Store] Improve bucket eviction with target-size and auto-eviction

    Enhance bucket eviction to support target-based eviction and automatic
    triggering when storage capacity is exceeded.

    Key improvements:
    - EvictBucket() now returns freed space size instead of void
    - TriggerBucketEviction() accepts target_free_size parameter
    - Loop eviction until target size is met (max 10 attempts)
    - Auto-trigger eviction in Allocate() when capacity exceeded
    - Update persisted_size_ after eviction to reflect freed space
    - Add AutoEvictionOnCapacityExceeded test

    This addresses the issue where single bucket eviction may not free
    enough space, and enables automatic space reclamation when the
    scheduler encounters capacity constraints.

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>

---------

Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>
2026-03-05 21:28:15 +08:00
Wan 9acd5689a0
[Store] implement p2p master service (#1611)
Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
2026-03-04 22:49:21 +08:00
Wan 48d3a47cdd
[Store]Refactor hierarchy MasterService and heartbeat mechanism 2026-03-04 14:42:59 +08:00
Shelron 80942798a3
[Store][Feature]Implement Remote data transfer in DataManager and PeerClient (#1428)
* Implement TransferDataToRemote and TransferDataFromRemote in DataManager

* resolve reviews

* parallel transfer request submit

* loopback

* [Store] Implement PeerClient async RPC and RDMA performance tests

Implement AsyncReadRemoteData/AsyncWriteRemoteData coroutine interfaces
for PeerClient, enabling concurrent RPC calls via collectAllPara. Add
comprehensive performance benchmarks comparing async vs sync at varying
concurrency levels, plus RDMA-enabled tests that measure real data
transfer throughput across different buffer sizes (4KB-1MB).

Key changes:
- peer_client.h/cpp: Add async single-key RPC interfaces using
  async_simple::coro::Lazy, implement Connect with client pool,
  wire sync/batch methods to delegate to async+syncAwait
- peer_client_perf_test.cpp: RPC-only benchmarks (PeerClientPerfTest)
  and RDMA data transfer benchmarks (PeerClientRdmaPerfTest) with
  MC_RDMA_DEVICE env var for single-NIC loopback filtering
- peer_client_test.cpp: Unit tests for PeerClient interfaces
- CMakeLists.txt: Add new test targets, temporarily exclude
  master_client.cpp due to yalantinglibs v0.5.6 incompatibility

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* [CI/Build] Re-enable master_client.cpp and centralized_master_client.cpp

These files were temporarily excluded due to a compilation error with
GCC 10 where yalantinglibs' util::is_invocable cannot handle abstract
class types (WrappedMasterService). The issue does not occur with
GCC 11+ which is the target build environment.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* [Store] Enhance RDMA perf tests: warmup, windowed concurrency, batch comparison

- Add warmup rounds to all RDMA tests to eliminate cold-start effects
  (QP connection setup, path resolution) that skewed measurements
- Add window parameter to RunRdmaAsyncReads/Writes for windowed
  concurrency via collectAllWindowedPara
- Add RdmaWindowedConcurrency test comparing window sizes {5,10,25,50,ALL}
- Add batch RPC helpers and RdmaSyncAsyncBatchComparison test for
  three-way sync vs async vs batch comparison
- Change minimum test data size from 4KB to 32KB to focus on
  meaningful transfer sizes where async consistently outperforms sync

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* [Store] Use median-of-5 sampling in RDMA perf tests for stability

Add MedianOf helper that runs each benchmark point 5 times and takes
the median, filtering out sporadic outliers caused by RDMA QP
contention, coroutine scheduling jitter, or shared pod noise. This
eliminates the occasional 0.03x-0.27x anomalies that appeared
randomly across different (size, N) combinations.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>

* add errlog and remove batch api

---------

Co-authored-by: chenwenxiao <chenwenxiaolive@gmail.com>
Co-authored-by: qinwenzh <zhengqinwen4@huawei.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Happy <yesreply@happy.engineering>
2026-02-14 15:53:35 +08:00
Wan b363dc9073
[Store] Separate the specific metadata management logic of the centralized Master architecture for P2P architecture implement (#1518)
* move function of master service into different service file according to rpc_service

* refactor master service

* fix metric test

* Update mooncake-store/include/centralized_master_client.h

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update mooncake-store/include/centralized_master_client.h

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* Update mooncake-store/src/centralized_master_service.cpp

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

* fix clangd format

---------

Co-authored-by: wanyue.wy <wanyue.wy@oceanbase.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2026-02-09 16:07:14 +08:00
chenwenxiaolive 034dc124d6 [Store] fix: Move variable declarations into #ifdef to fix unused variable warnings
Move dest_ptr and src_ptr declarations into USE_ASCEND_CACHE_TIER block
to avoid unused variable warnings when the macro is not defined.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive de863db9de [Store] fix: Fix unreachable code in CopyAscendToDram and CopyDramToAscend
Move return statements into #ifdef branch to avoid unreachable code
warning when USE_ASCEND_CACHE_TIER is not defined.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive e4f4128faf [Store] style: Apply clang-format-20 formatting
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive d335215b0b [Store] fix: Move return statement to avoid unreachable code warning
Move is_initialized_ assignment and return into #ifdef branch to avoid
compiler warning about unreachable code after return in #else branch.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 591bb9edcc [Store] fix: Return error instead of fallback when USE_ASCEND_CACHE_TIER not defined
Remove fallback mode that silently degrades to host memory when
USE_ASCEND_CACHE_TIER is not enabled. Now Init() returns INTERNAL_ERROR
with a clear message asking user to rebuild with the correct flag.

This prevents unexpected behavior when user configures ASCEND_NPU tier
but compiles without enabling the feature.

Changes:
- Init(): Return error instead of initializing in fallback mode
- AllocateDeviceMemory(): Return nullptr instead of using malloc
- ReleaseMemory(): Log error instead of calling free
- CopyAscendToDram/CopyDramToAscend(): Return error instead of memcpy

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
qinwenzh d8918d509e [Store][Fix] Fix ascend_tier_test: use DataCopier for copy verification
The CopyData API was changed to use key-based interface. Update
CopyAscendToDramWithVerification test to use DataCopier.Copy() directly
with a non-owning BufferRef wrapper.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 1717e928ae [Store] feat: Add ACL framework cleanup with aclFinalize
- Register std::atexit cleanup function to call aclFinalize
- Ensures proper resource cleanup on program exit
- Prevents resource leak warnings from analysis tools
- Addresses Gemini Code Assist review feedback

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 2163ab20ed [Store] test: Add CopyAscendToDram verification test
- Add CopyAscendToDramWithVerification test case
- Test validates Ascend->DRAM copy with data verification
- Addresses Gemini Code Assist review feedback

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 899a46e07a [Store] fix: Correct AclMemcpyWithDevice dst_size and data() return value
- Fix AclMemcpyWithDevice to use dst.buffer->size() for dst_size parameter
  (should be max allocated size, not copy size per ACL API spec)
- Change AscendBuffer::data() to return device_ptr instead of
  AscendUnifiedPointer address for standard BufferBase semantics
- Update documentation to reflect data() behavior change

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 73a0585bb4 [Store] refactor: Reduce code duplication in copy functions
- Remove redundant null check for backend_ assignment
- Extract common validation logic outside #ifdef blocks in
  CopyAscendToDram and CopyDramToAscend
- Reduce code duplication by 60 lines

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 7d38918fa8 [Store] refactor: Use type-safe cast in copy functions
- Replace reinterpret_cast with dynamic_cast + GetUnifiedPointer()
  in CopyAscendToDram and CopyDramToAscend
- Add explicit type checking for AscendBuffer
- Improve error messages for invalid buffer types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive b7957ee2f1 [Store] style: Add defensive null check before backend_ assignment
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 95e36ea5e3 [Store] test: Fix test assertions and comments in ascend_tier_test
- Add conditional assertions for invalid device ID test based on
  USE_ASCEND_CACHE_TIER macro
- Fix misleading comments in DestructorCleansUpAllocations test
- Add usage verification after cleanup

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 39af9953af [Store] fix: Add missing .get() calls for unique_ptr in AscendBuffer
- Fix data() to call unified_ptr_.get() before casting
- Fix GetUnifiedPointer() to return unified_ptr_.get()

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive e9c82477d3 [Store] refactor: Use std::unique_ptr for AscendUnifiedPointer ownership
- Change AscendBuffer to accept std::unique_ptr<AscendUnifiedPointer>
- Change unified_ptr_ member from raw pointer to std::unique_ptr
- Update AllocateDeviceMemory to return std::unique_ptr
- Simplify move semantics using std::move
- Use unified_ptr_.reset() instead of manual delete
- Update tests to use std::make_unique

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive dd94ad25e7 [Store] style: Apply clang-format-20 to Ascend tier code
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 949c9f6bf0 [Store][Fix] Add aclInit() call before using ACL functions
The ascend_tier_test was crashing because ACL functions like
aclrtGetDeviceCount() and aclrtSetDevice() were being called
without first initializing the ACL framework via aclInit().

This fix adds a thread-safe static initialization of ACL in
AscendCacheTier::Init() that:
- Calls aclInit() exactly once across all instances
- Handles ACL_ERROR_REPEAT_INITIALIZE gracefully if ACL is
  already initialized by other components
- Returns an error if ACL initialization fails

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 254e51aab9 [Store][Fix] Fix ascend_tier_test: remove non-existent TieredBackend::Read call
TieredBackend doesn't have a Read method. Updated the
CopyBetweenAscendTiersSameDevice test to verify allocation tier
type instead of attempting to read data.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 9d9028b467 [Store][Fix] Fix thread safety issues in AscendCacheTier
- Fix race condition in Allocate() using compare-and-swap (CAS) operation
  to atomically check and reserve space before device memory allocation
- Upgrade memory ordering from relaxed to acquire/release for proper
  cross-thread visibility of usage counter updates
- Add rollback logic when device memory allocation fails after space
  reservation

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
chenwenxiaolive 7ca1b447ae [Store][Feature] Add Ascend NPU cache tier support
Add AscendCacheTier implementation for Huawei Ascend NPU devices:

- Add ASCEND_NPU to MemoryType enum
- Implement AscendBuffer (RAII wrapper for device memory)
- Implement AscendCacheTier (Allocate/Free API)
- Register CopyAscendToDram and CopyDramToAscend copy functions
- Add TieredBackend integration for ASCEND_NPU tier type
- Add conditional compilation with USE_ASCEND_CACHE_TIER option
- Add comprehensive unit tests

Build with Ascend support:
  cmake .. -DUSE_ASCEND_CACHE_TIER=ON

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-03 20:38:47 +08:00
Xun Sun d31ebffe95 [CI] Support torch==2.10.0 (#1420) 2026-02-03 20:36:49 +08:00
Shelron ca16744df1
[Store][Feature]Introduce DataManager for unified local + remote data access (#1347)
* client rpc接口定义和data_manager初步实现

* 解决编译问题

* 补充头文件依赖

* 删除多余代码

* client集成改为optional

* add data manager test and adapt to new DataSource

* stub implementation and format change

* clang-formatting

* add lock contention test

* clang-format code style

* implement client rpc service

* Add tests for read lock removal safety verification

Added two test cases to verify that removing read locks from
DataManager::Get and ReadRemoteData is safe:
- ConcurrentGetAndDelete: Tests concurrent Get/Delete operations
- HandleKeepsDataAliveAfterDelete: Verifies handle keeps data alive after deletion

These tests validate that TieredBackend's internal locking and shared_ptr
reference counting provide sufficient thread safety.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* follow clang-format

* follow clang-format

---------

Co-authored-by: ccccccxy <chenxiaoyan32@huawei.com>
Co-authored-by: chenwenxiaolive <chenwenxiaolive@gmail.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 17:56:40 +08:00
Wan 3bb98aae29
Merge pull request #1362 from wanyue-wy/uncouple_master
[Store][Feature]Extract common interfaces of rpc_service and master_client for the P2P architecture
2026-01-13 19:43:43 +08:00
wanyue.wy e27a814878 Divide the RPC-related interfaces for P2P and Centralization architectures 2026-01-13 09:23:23 +00:00
Wan bd71efe05a
Merge pull request #1314 from openanolis/xinyi/tiered-backend-next
[Store] Tiered Backend add Dram tier support
2026-01-08 12:50:29 +08:00
Xingrui Yi 751d5f6122 [Store] tiered backend remove FreeInternal func
Signed-off-by: Xingrui Yi <yixingrui@linux.alibaba.com>
2026-01-08 11:54:26 +08:00