Skip to content

Commit

Permalink
HPCC-33045 Add an option to check size consistency within the write s…
Browse files Browse the repository at this point in the history
…ync margin

Signed-off-by: Gavin Halliday <[email protected]>
  • Loading branch information
ghalliday committed Nov 28, 2024
1 parent 8e7d451 commit bc2dbc3
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions dali/base/dadfs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,32 @@ enum MDFSRequestKind
MDFS_MAX
};


//--------------------------------------------------------------------------------------------------------------------

static unsigned dadfsHookId = 0;
static bool expertVerifyWriteSyncSizes = false;

//Add any code for caching global configuration here...
MODULE_INIT(INIT_PRIORITY_STANDARD)
{
auto updateFunc = [&](const IPropertyTree *oldComponentConfiguration, const IPropertyTree *oldGlobalConfiguration)
{
Owned<IPropertyTree> componentConfig = getComponentConfig();
Owned<IPropertyTree> globalConfig = getGlobalConfig();
expertVerifyWriteSyncSizes = componentConfig->getPropBool("expert/@verifyWriteSyncSizes", globalConfig->getPropBool("expert/@verifyWriteSyncSizes", false));
};
dadfsHookId = installConfigUpdateHook(updateFunc, true);
return true;
}

MODULE_EXIT()
{
removeConfigUpdateHook(dadfsHookId);
}

//--------------------------------------------------------------------------------------------------------------------

// Mutex for physical operations (remove/rename)
static CriticalSection physicalChange;

Expand Down Expand Up @@ -3813,13 +3839,33 @@ protected: friend class CDistributedFilePart;
if (unlikely(elapsedMs < marginMs))
{
LOG(MCuserProgress, "Delaying access to %s on %s for %ums to ensure write sync", queryLogicalName(), name, (unsigned)(marginMs - elapsedMs));
if (expertVerifyWriteSyncSizes)
checkSizeConsistency("Before write sync delay");
MilliSleep(marginMs - elapsedMs);
if (expertVerifyWriteSyncSizes)
checkSizeConsistency("After write sync delay");
now = 0; // re-evaluate now - unlikely to actually happen
}
}
}
}

void checkSizeConsistency(const char * when)
{
auto checkPartSize = [this,when](unsigned idx) -> void
{
IDistributedFilePart &part = queryPart(idx);
offset_t size = part.getDiskSize(false, false);
if (size != (offset_t)-1)
{
offset_t physicalSize = part.getDiskSize(true, true);
if (size != physicalSize)
OWARNLOG("%s: Part %d of file %s is inconsistent: logical size = %" I64F "d, physical size = %" I64F "d", when, idx, queryLogicalName(), size, physicalSize);
}
};
asyncFor(numParts(), checkPartSize);
}

bool hasDirPerPart() const
{
return FileDescriptorFlags::none != (fileFlags & FileDescriptorFlags::dirperpart);
Expand Down

0 comments on commit bc2dbc3

Please sign in to comment.