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

Fix metrics Worker.ActiveClients counter error #14088

Merged
merged 1 commit into from
Jan 25, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ public void closeUfsBlock(long sessionId, long blockId)
// the sessionId.
LOG.debug("Invalid worker state while committing block.", e);
}
} else {
// When getTempBlockMeta() return null, such as a block readType NO_CACHE writeType THROUGH.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xichen01 Would you please show the cause why counter was not be decreased in the commitblock()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the block metadata is not in memory (mLocalBlockStore.getTempBlockMeta() will return null). So, the branch commitblock() will not be executed.

if (mLocalBlockStore.getTempBlockMeta(sessionId, blockId) != null) {
try {
commitBlock(sessionId, blockId, false);

Why block metadata is not in memory?
When executing the test case: allxuio runTest --readType NO_CACHE --writeType THROUGH. the counter metric

if (mBlockWriter == null && offset == 0 && !mBlockMeta.isNoCache()) {
BlockStoreLocation loc = BlockStoreLocation.anyDirInTier(mStorageTierAssoc.getAlias(0));
mLocalBlockStore.createBlock(mBlockMeta.getSessionId(), mBlockMeta.getBlockId(),
AllocateOptions.forCreate(mInitialBlockSize, loc));

The block metadata will not update to memory, because is no_cache IO

// Counter will not be decrement in the commitblock().
// So we should decrement counter here.
if (mUnderFileSystemBlockStore.isNoCache(sessionId, blockId)) {
Metrics.WORKER_ACTIVE_CLIENTS.dec();
}
}
} finally {
mUnderFileSystemBlockStore.releaseAccess(sessionId, blockId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ public BlockReader getBlockReader(final long sessionId, long blockId, long offse
return reader;
}

/**
* @param sessionId the session ID
* @param blockId the block ID
* @return true if mNoCache is set
*/
public boolean isNoCache(long sessionId, long blockId) {
Key key = new Key(sessionId, blockId);
BlockInfo blockInfo = mBlocks.get(key);
UnderFileSystemBlockMeta mMeta = blockInfo.getMeta();
return mMeta.isNoCache();
}

/**
* Gets the {@link UnderFileSystemBlockMeta} for a session ID and block ID pair.
*
Expand Down