Steve Yurong Su created IOTDB-5925:
--------------------------------------

             Summary: Pipe: WAL Resource Management
                 Key: IOTDB-5925
                 URL: https://issues.apache.org/jira/browse/IOTDB-5925
             Project: Apache IoTDB
          Issue Type: Task
            Reporter: Steve Yurong Su


This code is designed to manage PipeWAL resources by implementing safe and 
efficient reference counting for these resources, as well as regularly checking 
if these resources have expired or become invalid to ensure code integrity. 

The `PipeWALResourceManager` class uses a `HashMap` called 
`memtableIdToPipeWALResourceMap` to store `PipeWALResource` objects mapped to 
their corresponding memtable IDs. It also uses an array of `ReentrantLocks` 
called `memtableIdSegmentLocks` to synchronize concurrent access to the 
`memtableIdToPipeWALResourceMap` hash map by dividing the map into segments 
based on the number of locks. 

The code schedules the `PIPE_WAL_RESOURCE_TTL_CHECKER`, a 
`ScheduledExecutorService`, using `IoTDBThreadPoolFactory`, to regularly check 
for expired or invalid resources, based on a minimum time to live in 
milliseconds. The `pin` and `unpin` methods increment and decrement the 
reference count for the memtable IDs respectively, ensuring that a memtable 
cannot be removed from the `memtableIdToPipeWALResourceMap` hash map if it is 
still being used by other clients. 

Finally, the `close` method cancels the `ttlCheckerFuture`, closes all 
remaining `PipeWALResource` objects and removes them from the 
`memtableIdToPipeWALResourceMap` hash map, while the `getReferenceCount` method 
returns the current reference count for a specified memtable ID.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to