Skip to content

Commit

Permalink
HPCC-33116 Suppress file check if invalid @compressedSize(0)
Browse files Browse the repository at this point in the history
Signed-off-by: Jake Smith <[email protected]>
  • Loading branch information
jakesmith committed Dec 11, 2024
1 parent 797e82d commit 3a3e674
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 14 deletions.
33 changes: 33 additions & 0 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13807,6 +13807,39 @@ void configurePreferredPlanes()
}
}

static bool doesPhysicalMatchMeta(IPropertyTree &partProps, IFile &iFile, offset_t &expectedSize, offset_t &actualSize)
{
// NB: temporary workaround for 'narrow' files publishing extra empty parts with the wrong @compressedSize(0)
// causing a new check introduced in HPCC-33064 to be hit (fixed in HPCC-33113, but will continue to affect exiting files)
unsigned __int64 size = partProps.getPropInt64("@size", (unsigned __int64)-1);
unsigned __int64 compressedSize = partProps.getPropInt64("@compressedSize", (unsigned __int64)-1);
if ((0 == size) && (0 == compressedSize))
return true;

if (expectedSize != unknownFileSize)
{
actualSize = iFile.size();
if (actualSize != expectedSize)
return false;
}
return true;
}

bool doesPhysicalMatchMeta(IPartDescriptor &partDesc, IFile &iFile, offset_t &expectedSize, offset_t &actualSize)
{
IPropertyTree &partProps = partDesc.queryProperties();
expectedSize = partDesc.getDiskSize(false, false);
return doesPhysicalMatchMeta(partProps, iFile, expectedSize, actualSize);
}

bool doesPhysicalMatchMeta(IDistributedFilePart &part, IFile &iFile, offset_t &expectedSize, offset_t &actualSize)
{
IPropertyTree &partProps = part.queryAttributes();
expectedSize = part.getDiskSize(false, false);
return doesPhysicalMatchMeta(partProps, iFile, expectedSize, actualSize);
}


#ifdef _USE_CPPUNIT
/*
* This method removes files only logically. removeEntry() used to do that, but the only
Expand Down
4 changes: 4 additions & 0 deletions dali/base/dadfs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -925,4 +925,8 @@ inline cost_type getLegacyWriteCost(const IPropertyTree & fileAttr, Source sourc
else
return 0;
}

extern da_decl bool doesPhysicalMatchMeta(IPartDescriptor &partDesc, IFile &iFile, offset_t &expectedSize, offset_t &actualSize);
extern da_decl bool doesPhysicalMatchMeta(IDistributedFilePart &partDesc, IFile &iFile, offset_t &expectedSize, offset_t &actualSize);

#endif
10 changes: 3 additions & 7 deletions ecl/hthor/hthor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8737,13 +8737,9 @@ bool CHThorDiskReadBaseActivity::openNext()

if (curPart)
{
offset_t expectedSize = curPart->getDiskSize(false, false);
if (expectedSize != unknownFileSize)
{
offset_t actualSize = inputfile->size();
if(actualSize != expectedSize)
throw MakeStringException(0, "File size mismatch: file %s was supposed to be %" I64F "d bytes but appears to be %" I64F "d bytes", inputfile->queryFilename(), expectedSize, actualSize);
}
offset_t expectedSize, actualSize;
if (!doesPhysicalMatchMeta(*curPart, *inputfile, expectedSize, actualSize))
throw makeStringExceptionV(0, "File size mismatch: file %s was supposed to be %" I64F "d bytes but appears to be %" I64F "d bytes", inputfile->queryFilename(), expectedSize, actualSize);
}

if (compressed)
Expand Down
10 changes: 3 additions & 7 deletions thorlcr/activities/diskread/thdiskreadslave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,9 @@ void CDiskRecordPartHandler::open()

rwFlags |= DEFAULT_RWFLAGS;

offset_t expectedSize = partDesc->getDiskSize(false, false);
if (expectedSize != unknownFileSize)
{
offset_t actualSize = iFile->size();
if(actualSize != expectedSize)
throw MakeStringException(0, "File size mismatch: file %s was supposed to be %" I64F "d bytes but appears to be %" I64F "d bytes", iFile->queryFilename(), expectedSize, actualSize);
}
offset_t expectedSize, actualSize;
if (!doesPhysicalMatchMeta(*partDesc, *iFile, expectedSize, actualSize))
throw MakeActivityException(&activity, 0, "File size mismatch: file %s was supposed to be %" I64F "d bytes but appears to be %" I64F "d bytes", iFile->queryFilename(), expectedSize, actualSize);

if (compressed)
{
Expand Down

0 comments on commit 3a3e674

Please sign in to comment.