You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ratis.apache.org by "Duong (Jira)" <ji...@apache.org> on 2024/04/17 01:57:00 UTC

[jira] [Updated] (RATIS-2059) Missing reference count when putting log entries to cache on follower

     [ https://issues.apache.org/jira/browse/RATIS-2059?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Duong updated RATIS-2059:
-------------------------
    Description: 
From RATIS-1979, when stateMachineCacheEnabled, the log entry is copied and decoupled from the original log entry reference counter.
{code:java}
     final LogEntryProto removedStateMachineData = LogProtoUtils.removeStateMachineData(entry);
    ....
     if (stateMachineCachingEnabled) {
        // The stateMachineData will be cached inside the StateMachine itself.
        cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
            ReferenceCountedObject.wrap(removedStateMachineData));
      } else {
        cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITHOUT_STATE_MACHINE_CACHE, entryRef
        );
      }
{code}
This opens a problem because in the below cases, *removedStateMachineData* is not a copy but the original entry itself. 
 # When the entry is a configuration or a metadata entry.
 # When the entry is a stateMachine and is replicated from leader to follower. Somehow, the state machine data ends up in *LogEntryProto.stateMachineLogEntry.logData* (and not {*}LogEntryProto.stateMachineLogEntry.stateMachineEntry.stateMachineData{*}). This makes the logic of removeStateMachineData completely skip the removal of state machine data.

 #2 is very concerning and I'm not sure it is a regression from another change. It makes it inconsistent that state machine data is available applyTransaction for followers (not the case for leader).

  was:
From RATIS-1979, when stateMachineCacheEnabled, the log entry is copied and decoupled from the original log entry reference counter.

 
 # tProtos.LogEntryProto removedStateMachineData = LogProt
 # oUtils.removeStateMachineData(entry); 
...
if (this.stateMachineCachingEnabled) \{ this.cache.appendEntry(Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE, ReferenceCountedObject.wrap(removedStateMachineData)); } else \{ this.cache.appendEntry(Op.WRITE_CACHE_WITHOUT_STATE_MACHINE_CACHE, entryRef); }

This opens a problem because in the below cases, *removedStateMachineData* is not a copy but the original entry itself. 

 
 # When the entry is a configuration or a metadata entry.
 # When the entry is a stateMachine and is replicated from leader to follower. Somehow, the state machine data ends up in *LogEntryProto.stateMachineLogEntry.logData* (and not {*}LogEntryProto.stateMachineLogEntry.stateMachineEntry.stateMachineData{*}). This makes the logic of removeStateMachineData completely skip the removal of state machine data.

 #2 is very concerning and I'm not sure it is a regression from another change. It makes it inconsistent that state machine data is available applyTransaction for followers (not the case for leader).


> Missing reference count when putting log entries to cache on follower
> ---------------------------------------------------------------------
>
>                 Key: RATIS-2059
>                 URL: https://issues.apache.org/jira/browse/RATIS-2059
>             Project: Ratis
>          Issue Type: Sub-task
>    Affects Versions: 3.1.0
>            Reporter: Duong
>            Priority: Major
>
> From RATIS-1979, when stateMachineCacheEnabled, the log entry is copied and decoupled from the original log entry reference counter.
> {code:java}
>      final LogEntryProto removedStateMachineData = LogProtoUtils.removeStateMachineData(entry);
>     ....
>      if (stateMachineCachingEnabled) {
>         // The stateMachineData will be cached inside the StateMachine itself.
>         cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITH_STATE_MACHINE_CACHE,
>             ReferenceCountedObject.wrap(removedStateMachineData));
>       } else {
>         cache.appendEntry(LogSegment.Op.WRITE_CACHE_WITHOUT_STATE_MACHINE_CACHE, entryRef
>         );
>       }
> {code}
> This opens a problem because in the below cases, *removedStateMachineData* is not a copy but the original entry itself. 
>  # When the entry is a configuration or a metadata entry.
>  # When the entry is a stateMachine and is replicated from leader to follower. Somehow, the state machine data ends up in *LogEntryProto.stateMachineLogEntry.logData* (and not {*}LogEntryProto.stateMachineLogEntry.stateMachineEntry.stateMachineData{*}). This makes the logic of removeStateMachineData completely skip the removal of state machine data.
>  #2 is very concerning and I'm not sure it is a regression from another change. It makes it inconsistent that state machine data is available applyTransaction for followers (not the case for leader).



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