Skip to content

Cleaner::DeleteOne里面的m_poCheckpointMgr->SetMinChosenInstanceIDCache的入参应该改为llInstanceID + 1 #223

@dyx2025

Description

@dyx2025

Cleaner::DeleteOne里面的m_poCheckpointMgr->SetMinChosenInstanceIDCache的入参应该改为llInstanceID + 1。

源代码路径:
src/checkpoint/cleaner.cpp

bool Cleaner :: DeleteOne(const uint64_t llInstanceID)
{
    WriteOptions oWriteOptions;
    oWriteOptions.bSync = false;

    int ret = m_poLogStorage->Del(oWriteOptions, m_poConfig->GetMyGroupIdx(), llInstanceID);
    if (ret != 0)
    {   
        return false;
    }   

    // m_poLogStorage->Del已经把llInstanceID的paxos log删除,当前的MinChosenInstanceID为llInstanceID + 1 
    // 入参应该是llInstanceID + 1 ,实际入参为llInstanceID,与预期不一致。
    m_poCheckpointMgr->SetMinChosenInstanceIDCache(llInstanceID);

    if (llInstanceID >= m_llLastSave + DELETE_SAVE_INTERVAL)
    {
        // m_poLogStorage->Del已经把llInstanceID的paxos log删除,当前的MinChosenInstanceID为llInstanceID + 1 
        // 入参应该是llInstanceID + 1 ,实际入参为llInstanceID + 1,与预期一致。
        int ret = m_poCheckpointMgr->SetMinChosenInstanceID(llInstanceID + 1); 
        if (ret != 0)
        {   
            PLGErr("SetMinChosenInstanceID fail, now delete instanceid %lu", llInstanceID);
            return false;
        }   

        m_llLastSave = llInstanceID;

        PLGImp("delete %d instance done, now minchosen instanceid %lu", 
                DELETE_SAVE_INTERVAL, llInstanceID + 1); 
    }   
                                                                                                                                                                                    
    return true;
}

src/checkpoint/cp_mgr.cpp

// CheckpointMgr::SetMinChosenInstanceIDCache 和 CheckpointMgr::SetMinChosenInstanceIDCache 都会把入参llMinChosenInstanceID赋予同一个变量m_llMinChosenInstanceID 

int CheckpointMgr :: SetMinChosenInstanceID(const uint64_t llMinChosenInstanceID)
{ 
    WriteOptions oWriteOptions;
    oWriteOptions.bSync = true;

    int ret = m_poLogStorage->SetMinChosenInstanceID(oWriteOptions, m_poConfig->GetMyGroupIdx(), llMinChosenInstanceID);
    if (ret != 0)
    {
        return ret;
    }

    m_llMinChosenInstanceID = llMinChosenInstanceID;

    return 0;
}

void CheckpointMgr :: SetMinChosenInstanceIDCache(const uint64_t llMinChosenInstanceID)
{
    m_llMinChosenInstanceID = llMinChosenInstanceID;
}

修改后代码:
src/checkpoint/cleaner.cpp

bool Cleaner :: DeleteOne(const uint64_t llInstanceID)
{
    WriteOptions oWriteOptions;
    oWriteOptions.bSync = false;

    int ret = m_poLogStorage->Del(oWriteOptions, m_poConfig->GetMyGroupIdx(), llInstanceID);
    if (ret != 0)
    {   
        return false;
    }   

    // m_poCheckpointMgr->SetMinChosenInstanceIDCache(llInstanceID);
    m_poCheckpointMgr->SetMinChosenInstanceIDCache(llInstanceID + 1);

    if (llInstanceID >= m_llLastSave + DELETE_SAVE_INTERVAL)
    {
        int ret = m_poCheckpointMgr->SetMinChosenInstanceID(llInstanceID + 1); 
        if (ret != 0)
        {   
            PLGErr("SetMinChosenInstanceID fail, now delete instanceid %lu", llInstanceID);
            return false;
        }   

        m_llLastSave = llInstanceID;

        PLGImp("delete %d instance done, now minchosen instanceid %lu", 
                DELETE_SAVE_INTERVAL, llInstanceID + 1); 
    }   
                                                                                                                                                                                    
    return true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions