From 8c33c9c9baf6a91e359deac39f64f94bf4a295e3 Mon Sep 17 00:00:00 2001 From: yh263208 Date: Tue, 17 Oct 2023 22:29:23 +0800 Subject: [PATCH 1/3] feat: make odc apapt to OceanBase 4.2.1 --- .../odc/core/shared/model/TraceSpan.java | 3 +-- .../odc/core/sql/util/FullLinkTraceUtil.java | 24 ++++++++++++------- .../odc/service/db/DBRecyclebinService.java | 3 ++- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/model/TraceSpan.java b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/model/TraceSpan.java index edbe03b24e..57df32cf40 100644 --- a/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/model/TraceSpan.java +++ b/server/odc-core/src/main/java/com/oceanbase/odc/core/shared/model/TraceSpan.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Locale; -import java.util.Map; import com.fasterxml.jackson.annotation.JsonAlias; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -44,7 +43,7 @@ public class TraceSpan { @JsonAlias("logs") private String logs; @JsonAlias("tags") - private List> tags; + private List tags; @JsonAlias("elapse") private Long elapseMicroSeconds; @JsonAlias("parent") diff --git a/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java b/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java index 2543186209..e2a54b1074 100644 --- a/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java +++ b/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java @@ -18,6 +18,7 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; +import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -32,6 +33,8 @@ public class FullLinkTraceUtil { + private final static String TRACE_ID_KEY = "log_trace_id"; + public static SqlExecTime getFullLinkTraceDetail(Statement statement) throws SQLException { OceanBaseConnection connection = (OceanBaseConnection) statement.getConnection(); long lastPacketResponseTimestamp = @@ -67,8 +70,8 @@ private static SqlExecTime parseSpanList(List spanList) { return v; }); } - if (traceId == null && parseLogTraceId(span.getTags()) != null) { - traceId = parseLogTraceId(span.getTags()); + if (traceId == null && findLogTraceId(span.getTags()) != null) { + traceId = findLogTraceId(span.getTags()); } span.setNode(Node.from(span.getSpanName())); if ("com_query_process".equals(span.getSpanName())) { @@ -89,13 +92,18 @@ private static SqlExecTime parseSpanList(List spanList) { return execDetail; } - private static String parseLogTraceId(List> tags) { - if (tags == null) { + private static String findLogTraceId(Object tags) { + if (tags instanceof Map) { + if (((Map) tags).containsKey(TRACE_ID_KEY)) { + return ((Map) tags).get(TRACE_ID_KEY).toString(); + } return null; - } - for (Map tag : tags) { - if (tag.containsKey("log_trace_id")) { - return (String) tag.get("log_trace_id"); + } else if (tags instanceof Collection) { + for (Object obj : (Collection) tags) { + String value = findLogTraceId(obj); + if (value != null) { + return value; + } } } return null; diff --git a/server/odc-service/src/main/java/com/oceanbase/odc/service/db/DBRecyclebinService.java b/server/odc-service/src/main/java/com/oceanbase/odc/service/db/DBRecyclebinService.java index 86648bb4d3..27467976d6 100644 --- a/server/odc-service/src/main/java/com/oceanbase/odc/service/db/DBRecyclebinService.java +++ b/server/odc-service/src/main/java/com/oceanbase/odc/service/db/DBRecyclebinService.java @@ -138,7 +138,8 @@ public String getFlashbackSql(@NonNull ConnectionSession session, List Date: Tue, 17 Oct 2023 22:33:57 +0800 Subject: [PATCH 2/3] update submodule --- client | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client b/client index fad5b97682..b942423e45 160000 --- a/client +++ b/client @@ -1 +1 @@ -Subproject commit fad5b9768298f53b256edeb08960cafa05427bc3 +Subproject commit b942423e456065427a0923002afe8de52e153cf9 From 17b67dd58bc927890da9d582e278a2227b0827e5 Mon Sep 17 00:00:00 2001 From: yh263208 Date: Wed, 18 Oct 2023 10:24:38 +0800 Subject: [PATCH 3/3] response to comments --- .../java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java b/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java index e2a54b1074..a65728827a 100644 --- a/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java +++ b/server/odc-core/src/main/java/com/oceanbase/odc/core/sql/util/FullLinkTraceUtil.java @@ -70,7 +70,7 @@ private static SqlExecTime parseSpanList(List spanList) { return v; }); } - if (traceId == null && findLogTraceId(span.getTags()) != null) { + if (traceId == null) { traceId = findLogTraceId(span.getTags()); } span.setNode(Node.from(span.getSpanName()));