Skip to content

[Bug Report] Wrong Unlock #336

@qingzhu521

Description

@qingzhu521

if you try

            TrinityConfig.CurrentRunningMode = RunningMode.Client;
            try {
                KCoreCell node_ins = Global.CloudStorage.LoadKCoreCell(0);
            }
            catch (Exception ex) {
                Console.WriteLine("cell not found");
            }
            var neighbors = new List<long>();
            Global.CloudStorage.SaveKCoreCell(0, alive: false, remain_nodes: 0, neighbors);

this code the server will break this is for in

            #region LoadCell
            tupleList.Add(new TypeSyncRequestResponseHandlerTuple
            {
                Id = (ushort)RequestType.LoadCell,
                Handler = delegate(SynReqRspArgs args)
                {
                    int index, cellSize;
                    byte* cellPtr = null;
                    TrinityErrorCode eResult;
                    long cellId = *(long*)(args.Buffer + args.Offset);
                    if ((eResult = CLocalMemoryStorage.CGetLockedCellInfo4LoadCell(cellId, out cellSize, out cellPtr, out index)) == TrinityErrorCode.E_CELL_NOT_FOUND)
                    {
                        args.Response = new TrinityMessage(eResult);
                    }
                    else
                    {
                        args.Response = new TrinityMessage(eResult, cellSize);
                        Memory.memcpy(args.Response.Buffer + TrinityMessage.Offset, cellPtr, (ulong)cellSize);
                    }
                    Log.WriteLine(LogLevel.Info, "Load Crelease lock {0} id {1} index", cellId, index);
                    CLocalMemoryStorage.CReleaseCellLock(cellId, index);
                }
            });

The storage will release the lock. But in load process there don't exit any lock on the cell.

            uint8_t MTHash::ReleaseEntryLock(const int32_t index)
            {
                    if (TrinityConfig::ReadOnly())
                         return 0;
                   Trinity::Diagnostics::WriteLine(Trinity::Diagnostics::Info, "UnKnow Release index {0} LOCK {1}", index, (int)MTEntries[index].EntryLock);
                  return (MTEntries[index].EntryLock.fetch_add(-1, std::memory_order_release) - 1);
           }

this code will put the entrylock into -1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions