[Bug Report] Wrong Unlock
qingzhu521 opened this issue · 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 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.
@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.
I'm testing a fix for this issue this week; I will keep you posted.
@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.
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 Thank you. I'll check out your code.
@shaobin Did we get time to review this in detail? I think I am running into the same problem.
@qingzhu521 Hi, did you ever get any type of resolution this your problem?
I think we can review this problem togather.
@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 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.
@qingzhu521 Are you using the DataImporter?
yes
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.