From 03f08942faaeccf930a9727c359ea2ea34ed3ddd Mon Sep 17 00:00:00 2001 From: duanmeng Date: Wed, 4 Dec 2024 11:38:10 -0800 Subject: [PATCH] fix: Flaky HashJoinReplayerTest.partialDriverIds (#11742) Summary: The trace data file for driver 0 might be empty. In such a case, the replayer would disregard the associated re-execution, thereby not triggering the injected failure. Add a file size check before the exception asserts in `HashJoinReplayerTest.partialDriverIds`. Fix https://github.com/facebookincubator/velox/issues/11695 Pull Request resolved: https://github.com/facebookincubator/velox/pull/11742 Reviewed By: Yuhta Differential Revision: D66767559 Pulled By: xiaoxmeng fbshipit-source-id: 75df35ca2a27f13f62831bceccd88415e7826e6e --- .../tool/trace/tests/HashJoinReplayerTest.cpp | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/velox/tool/trace/tests/HashJoinReplayerTest.cpp b/velox/tool/trace/tests/HashJoinReplayerTest.cpp index 53567d48f027..dcd840d217c0 100644 --- a/velox/tool/trace/tests/HashJoinReplayerTest.cpp +++ b/velox/tool/trace/tests/HashJoinReplayerTest.cpp @@ -289,22 +289,25 @@ TEST_F(HashJoinReplayerTest, partialDriverIds) { const auto opTraceDataFile = exec::trace::getOpTraceInputFilePath(opTraceDir); auto faultyFs = faultyFileSystem(); faultyFs->setFileInjectionHook([&](FaultFileOperation* op) { - if (op->type == FaultFileOperation::Type::kRead && + if ((op->type == FaultFileOperation::Type::kRead || + op->type == FaultFileOperation::Type::kReadv) && op->path == opTraceDataFile) { VELOX_FAIL("Read wrong data file {}", opTraceDataFile); } }); - VELOX_ASSERT_THROW( - HashJoinReplayer( - traceRoot, - task->queryCtx()->queryId(), - task->taskId(), - traceNodeId_, - "HashJoin", - "0") - .run(), - "Read wrong data file"); + if (faultyFs->openFileForRead(opTraceDataFile)->size() > 0) { + VELOX_ASSERT_THROW( + HashJoinReplayer( + traceRoot, + task->queryCtx()->queryId(), + task->taskId(), + traceNodeId_, + "HashJoin", + "0") + .run(), + "Read wrong data file"); + } HashJoinReplayer( traceRoot, task->queryCtx()->queryId(),