Skip to content

Pipe: Avoid lock acquisition in pipe task agent for too long #15836

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -283,6 +283,7 @@ public enum TSStatusCode {
PIPE_RECEIVER_USER_CONFLICT_EXCEPTION(1810),
PIPE_CONFIG_RECEIVER_HANDSHAKE_NEEDED(1811),
PIPE_TRANSFER_SLICE_OUT_OF_ORDER(1812),
PIPE_PUSH_META_TIMEOUT(1813),

// Subscription
SUBSCRIPTION_VERSION_ERROR(1900),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,14 @@ public static String parsePushPipeMetaExceptionForPipe(
int dataNodeId = respEntry.getKey();
TPushPipeMetaResp resp = respEntry.getValue();

if (resp.getStatus().getCode() == TSStatusCode.PIPE_PUSH_META_TIMEOUT.getStatusCode()) {
exceptionMessageBuilder.append(
String.format(
"DataNodeId: %s, Message: Timeout to wait for lock while processing pushPipeMeta on dataNodes.",
dataNodeId));
continue;
}

if (resp.getStatus().getCode() == TSStatusCode.PIPE_PUSH_META_ERROR.getStatusCode()) {
if (!resp.isSetExceptionMessages()) {
exceptionMessageBuilder.append(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.iotdb.db.pipe.agent.task;

import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.consensus.DataRegionId;
import org.apache.iotdb.commons.consensus.SchemaRegionId;
import org.apache.iotdb.commons.consensus.index.ProgressIndex;
Expand Down Expand Up @@ -397,7 +398,8 @@ public void stopAllPipesWithCriticalException() {
public void collectPipeMetaList(final TDataNodeHeartbeatResp resp) throws TException {
// Try the lock instead of directly acquire it to prevent the block of the cluster heartbeat
// 10s is the half of the HEARTBEAT_TIMEOUT_TIME defined in class BaseNodeCache in ConfigNode
if (!tryReadLockWithTimeOut(10)) {
if (!tryReadLockWithTimeOut(
CommonDescriptor.getInstance().getConfig().getDnConnectionTimeoutInMS() * 2L / 3)) {
return;
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,10 @@ public TPushPipeMetaResp pushPipeMeta(final TPushPipeMetaReq req) {
.map(PipeMeta::deserialize4TaskAgent)
.collect(Collectors.toList()));

if (Objects.isNull(exceptionMessages)) {
return new TPushPipeMetaResp()
.setStatus(new TSStatus(TSStatusCode.PIPE_PUSH_META_TIMEOUT.getStatusCode()));
}
return exceptionMessages.isEmpty()
? new TPushPipeMetaResp()
.setStatus(new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode()))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.apache.iotdb.commons.pipe.agent.task;

import org.apache.iotdb.commons.conf.CommonDescriptor;
import org.apache.iotdb.commons.exception.IllegalPathException;
import org.apache.iotdb.commons.exception.pipe.PipeRuntimeConnectorCriticalException;
import org.apache.iotdb.commons.exception.pipe.PipeRuntimeCriticalException;
Expand Down Expand Up @@ -337,7 +338,10 @@ protected TPushPipeMetaRespExceptionMessage handleDropPipeInternal(final String

public List<TPushPipeMetaRespExceptionMessage> handlePipeMetaChanges(
final List<PipeMeta> pipeMetaListFromCoordinator) {
acquireWriteLock();
if (!tryWriteLockWithTimeOut(
CommonDescriptor.getInstance().getConfig().getDnConnectionTimeoutInMS() * 2L / 3)) {
return null;
}
try {
return handlePipeMetaChangesInternal(pipeMetaListFromCoordinator);
} finally {
Expand Down Expand Up @@ -1052,7 +1056,10 @@ private void stopAllPipesWithCriticalExceptionInternal(final int currentNodeId)

public void collectPipeMetaList(final TPipeHeartbeatReq req, final TPipeHeartbeatResp resp)
throws TException {
acquireReadLock();
if (!tryReadLockWithTimeOut(
CommonDescriptor.getInstance().getConfig().getDnConnectionTimeoutInMS() * 2L / 3)) {
return;
}
try {
collectPipeMetaListInternal(req, resp);
} finally {
Expand Down
Loading