Skip to content

Commit

Permalink
fix: Fix trace exception and code refactor (facebookincubator#11965)
Browse files Browse the repository at this point in the history
Summary:
1. "VELOX_SPILL_LIMIT_EXCEEDED" -> "VELOX_TRACE_LIMIT_EXCEEDED" in updateTracedBytesAndCheckLimit().
2. Typo in the comment of OperatorTraceTest.

Pull Request resolved: facebookincubator#11965

Reviewed By: gggrace14

Differential Revision: D67653883

Pulled By: xiaoxmeng

fbshipit-source-id: 4effe4637a2ccc8c103721087b854059b60c53a2
  • Loading branch information
xiaodouchen authored and facebook-github-bot committed Dec 27, 2024
1 parent 646d4a9 commit c046524
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
3 changes: 2 additions & 1 deletion velox/common/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ velox_add_library(
SpillConfig.cpp
SpillStats.cpp
StatsReporter.cpp
SuccinctPrinter.cpp)
SuccinctPrinter.cpp
TraceConfig.cpp)

velox_link_libraries(
velox_common_base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
* limitations under the License.
*/

#include "velox/exec/TraceConfig.h"

#include <utility>

#include "velox/common/base/Exceptions.h"
#include "velox/common/base/TraceConfig.h"

namespace facebook::velox::exec::trace {

Expand Down
9 changes: 9 additions & 0 deletions velox/exec/TraceConfig.h → velox/common/base/TraceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@

namespace facebook::velox::exec::trace {

#define VELOX_TRACE_LIMIT_EXCEEDED(errorMessage) \
_VELOX_THROW( \
::facebook::velox::VeloxRuntimeError, \
::facebook::velox::error_source::kErrorSourceRuntime.c_str(), \
::facebook::velox::error_code::kTraceLimitExceeded.c_str(), \
/* isRetriable */ true, \
"{}", \
errorMessage);

/// The callback used to update and aggregate the trace bytes of a query. If the
/// query trace limit is set, the callback return true if the aggregate traced
/// bytes exceed the set limit otherwise return false.
Expand Down
3 changes: 2 additions & 1 deletion velox/core/QueryCtx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "velox/core/QueryCtx.h"
#include "velox/common/base/SpillConfig.h"
#include "velox/common/base/TraceConfig.h"
#include "velox/common/config/Config.h"

namespace facebook::velox::core {
Expand Down Expand Up @@ -90,7 +91,7 @@ void QueryCtx::updateSpilledBytesAndCheckLimit(uint64_t bytes) {
void QueryCtx::updateTracedBytesAndCheckLimit(uint64_t bytes) {
if (numTracedBytes_.fetch_add(bytes) + bytes >=
queryConfig_.queryTraceMaxBytes()) {
VELOX_SPILL_LIMIT_EXCEEDED(fmt::format(
VELOX_TRACE_LIMIT_EXCEEDED(fmt::format(
"Query exceeded per-query local trace limit of {}",
succinctBytes(queryConfig_.queryTraceMaxBytes())));
}
Expand Down
1 change: 0 additions & 1 deletion velox/exec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ velox_add_library(
TaskTraceReader.cpp
TaskTraceWriter.cpp
Trace.cpp
TraceConfig.cpp
TraceUtil.cpp
PartitionedOutput.cpp
PartitionFunction.cpp
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@

#include "velox/common/base/Counters.h"
#include "velox/common/base/StatsReporter.h"
#include "velox/common/base/TraceConfig.h"
#include "velox/common/time/CpuWallTimer.h"
#include "velox/core/PlanFragment.h"
#include "velox/core/QueryCtx.h"
#include "velox/exec/TraceConfig.h"

namespace facebook::velox::exec {

Expand Down
2 changes: 1 addition & 1 deletion velox/exec/OperatorTraceWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#include "TraceConfig.h"
#include "velox/common/base/TraceConfig.h"
#include "velox/common/file/File.h"
#include "velox/common/file/FileSystems.h"
#include "velox/exec/Split.h"
Expand Down
2 changes: 1 addition & 1 deletion velox/exec/Task.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#pragma once

#include "velox/common/base/SkewedPartitionBalancer.h"
#include "velox/common/base/TraceConfig.h"
#include "velox/core/PlanFragment.h"
#include "velox/core/QueryCtx.h"
#include "velox/exec/Driver.h"
Expand All @@ -27,7 +28,6 @@
#include "velox/exec/TaskStats.h"
#include "velox/exec/TaskStructs.h"
#include "velox/exec/TaskTraceWriter.h"
#include "velox/exec/TraceConfig.h"
#include "velox/vector/ComplexVector.h"

namespace facebook::velox::exec {
Expand Down
8 changes: 0 additions & 8 deletions velox/exec/Trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,4 @@ struct OperatorTraceSummary {
std::string toString() const;
};

#define VELOX_TRACE_LIMIT_EXCEEDED(errorMessage) \
_VELOX_THROW( \
::facebook::velox::VeloxRuntimeError, \
::facebook::velox::error_source::kErrorSourceRuntime.c_str(), \
::facebook::velox::error_code::kTraceLimitExceeded.c_str(), \
/* isRetriable */ true, \
"{}", \
errorMessage);
} // namespace facebook::velox::exec::trace
2 changes: 1 addition & 1 deletion velox/exec/tests/OperatorTraceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ TEST_F(OperatorTraceTest, error) {
.copyResults(pool()),
"Query trace enabled but the trace dir is not set");
}
// Duplicate trace plan node ids.
// No trace task regexp.
{
const auto queryConfigs = std::unordered_map<std::string, std::string>{
{core::QueryConfig::kQueryTraceEnabled, "true"},
Expand Down

0 comments on commit c046524

Please sign in to comment.