Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HPCC-31497 Improve error details if unexpected node type read from index #18427

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions system/jhtree/jhtree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2441,7 +2441,7 @@ class CLazyKeyIndex : implements IKeyIndex, public CInterface
virtual IKeyIndex *queryPart(unsigned idx) { return idx ? NULL : this; }
virtual unsigned queryScans() { return realKey ? realKey->queryScans() : 0; }
virtual unsigned querySeeks() { return realKey ? realKey->querySeeks() : 0; }
virtual const char *queryFileName() { return keyfile.get(); }
virtual const char *queryFileName() const { return keyfile.get(); }
virtual offset_t queryBlobHead() { return checkOpen().queryBlobHead(); }
virtual void resetCounts() { if (realKey) realKey->resetCounts(); }
virtual offset_t queryLatestGetNodeOffset() const { return realKey ? realKey->queryLatestGetNodeOffset() : 0; }
Expand Down Expand Up @@ -2659,7 +2659,14 @@ const CJHTreeNode *CNodeCache::getNode(const INodeLoader *keyIndex, unsigned iD,
if (!ownedCacheEntry->isReady())
{
const CJHTreeNode *node = keyIndex->loadNode(&fetchCycles, pos);
assertex(type == node->getNodeType());
if (unlikely(type != node->getNodeType()))
{
//This should never happen, but if it does, report as much information as possible to diagnose the issue.
StringBuffer msg;
msg.appendf("Node type mismatch for node %s@%llx (expected %s, got %s)", keyIndex->queryFileName(), pos, cacheTypeText[type], cacheTypeText[node->getNodeType()]);
node->Release();
throwUnexpectedX(msg);
}

//Update the associated size of the entry in the hash table before setting isReady (never evicted until isReady is set)
curCache.noteReady(*node);
Expand Down
2 changes: 1 addition & 1 deletion system/jhtree/jhtree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ interface jhtree_decl IKeyIndex : public IKeyIndexBase
virtual unsigned querySeeks() = 0;
virtual size32_t keyedSize() = 0;
virtual bool hasPayload() = 0;
virtual const char *queryFileName() = 0;
virtual const char *queryFileName() const = 0;
virtual offset_t queryBlobHead() = 0;
virtual void resetCounts() = 0;
virtual offset_t queryLatestGetNodeOffset() const = 0;
Expand Down
7 changes: 5 additions & 2 deletions system/jhtree/jhtree.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ interface INodeLoader
virtual const CJHTreeNode *loadNode(cycle_t * fetchCycles, offset_t offset) const = 0;
virtual const CJHSearchNode *locateFirstLeafNode(IContextLogger *ctx) const = 0;
virtual const CJHSearchNode *locateLastLeafNode(IContextLogger *ctx) const = 0;
virtual const char *queryFileName() const = 0;
};

class jhtree_decl CKeyIndex : implements IKeyIndex, implements INodeLoader, public CInterface
Expand Down Expand Up @@ -161,6 +162,8 @@ public:
virtual const CJHSearchNode *locateLastLeafNode(IContextLogger *ctx) const override;

virtual void mergeStats(CRuntimeStatisticCollection & stats) const override {}

virtual const char *queryFileName() const = 0;
};

class jhtree_decl CMemKeyIndex : public CKeyIndex
Expand All @@ -170,7 +173,7 @@ private:
public:
CMemKeyIndex(unsigned _iD, IMemoryMappedFile *_io, const char *_name, bool _isTLK);

virtual const char *queryFileName() { return name.get(); }
virtual const char *queryFileName() const { return name.get(); }
virtual const IFileIO *queryFileIO() const override { return nullptr; }
// INodeLoader impl.
virtual const CJHTreeNode *loadNode(cycle_t * fetchCycles, offset_t offset) const override;
Expand All @@ -186,7 +189,7 @@ private:
public:
CDiskKeyIndex(unsigned _iD, IFileIO *_io, const char *_name, bool _isTLK);

virtual const char *queryFileName() { return name.get(); }
virtual const char *queryFileName() const { return name.get(); }
virtual const IFileIO *queryFileIO() const override { return io; }
// INodeLoader impl.
virtual const CJHTreeNode *loadNode(cycle_t * fetchCycles, offset_t offset) const override;
Expand Down
Loading