GraphEngine icon indicating copy to clipboard operation
GraphEngine copied to clipboard

[Bug Report] Wrong Unlock

Open qingzhu521 opened this issue 4 years ago • 15 comments

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.

qingzhu521 avatar Aug 05 '21 07:08 qingzhu521

image

The line 61 should be in 58 Bracket

qingzhu521 avatar Aug 05 '21 09:08 qingzhu521

@qingzhu521 Thanks for reporting this and sorry for this oversight; I will include a new unit-test case to sniff this out. I can't update this repo but I will update my forked repo and get the fix in this coming week. I'll also post where one can get the new Nuget packages.

TaviTruman avatar Aug 07 '21 07:08 TaviTruman

@qingzhu521 I have a new fork of the Graph Engine here: https://github.com/InKnowWorks/IKW-GraphEngine. We have a lot of updates coming to address bugs, updated and additional documentation as well as new capabilities in the new year.

TaviTruman avatar Dec 01 '21 22:12 TaviTruman

I'm testing a fix for this issue this week; I will keep you posted.

TaviTruman avatar Apr 04 '22 21:04 TaviTruman

@qingzhu521 Thanks for reporting this! @TaviTruman , Thank you for trying to address this!

@qingzhu521 Could you help provide the minimal source code (with TSL etc.) that can reproduce this issue? I'd like to take a look at this issue.

shaobin avatar May 22 '22 04:05 shaobin

Kcore.txt GraphEng.txt @shaobin There has been some time since this program, But I think this is the code. I try to implement KCore algorithm in Trinity which trigger this problem.

qingzhu521 avatar May 24 '22 13:05 qingzhu521

@qingzhu521 Thank you. I'll check out your code.

shaobin avatar May 24 '22 14:05 shaobin

@shaobin Did we get time to review this in detail? I think I am running into the same problem.

TaviTruman avatar Oct 18 '22 19:10 TaviTruman

@qingzhu521 Hi, did you ever get any type of resolution this your problem?

TaviTruman avatar Dec 02 '22 20:12 TaviTruman

I think we can review this problem togather.

qingzhu521 avatar Dec 09 '22 01:12 qingzhu521

@TaviTruman I think is not hard to reproduce this problem. I just write a program that every time trinity can deal with a batch of data. Then the bug produced.

qingzhu521 avatar Dec 09 '22 01:12 qingzhu521

@qingzhu521 I have isolated the code template in the TSL Code Generator (C++). I will rebuild and test when I get a free hour or so. I'll also add a new test in the build.

TaviTruman avatar Dec 09 '22 17:12 TaviTruman

@qingzhu521 Are you using the DataImporter?

TaviTruman avatar Dec 09 '22 17:12 TaviTruman

yes

qingzhu521 avatar Dec 30 '22 02:12 qingzhu521

Cool. I have a number of fixes and updates. I don't think the Dataimporter is supported in the repo. Have you made any updates to the utility. I'm working to prepare a PR for this repo UT have already updated my forked repo copy.

TaviTruman avatar Dec 30 '22 06:12 TaviTruman