diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md index 1fb8e2436b46..b14c27926c36 100644 --- a/docs/en/changes/changes.md +++ b/docs/en/changes/changes.md @@ -41,6 +41,7 @@ * BanyanDB: fix dropping a measure, as removing a runtime rule or changing a metric's function with `allowStorageChange` does, leaving its pre-built TopN aggregations behind on the dropped measure. The drop deleted a TopN aggregation named after the measure, but each is named after its `bydb-topn.yml` rule, so none was deleted, and a measure created again under the same name found the old ones in place and kept their old definition. It now deletes every TopN aggregation whose source is the dropped measure, and when one fails to delete it stops before the measure, so the removal fails and is tried again instead of leaving that aggregation behind. * Fix the trace and Zipkin queries putting an event of eBPF profiling on the wrong span, or losing it. A server-side event (a request read, or a response written, on the server, attached to the client's span through its trace context) belongs on the server's span, while the client-side events of that span stay on it; but the span an event went to was remembered by the span the event named alone, so every event of a span followed its first one. On a Zipkin trace, a span that took both its own events and the server-side events of its client span was also rebuilt twice, keeping only one of the two sets. Each event now goes to the span of its own side. * Fix span-attached events of eBPF profiling overwriting each other. An event's storage ID was its segment ID, start time and name. Rover sends a Zipkin event with an empty segment ID, so two Zipkin events with the same name and start time, in any two traces, had one ID, and so could two SkyWalking events on different spans of one segment. Elasticsearch kept only the one written last, and JDBC, whose row key is the same ID, cannot hold both. The ID now also carries the trace ID and span ID. +* Fix JDBC trace profiling queries failing when a task has no profiled segments: the empty segment-ID list now returns an empty result without generating an invalid SQL `IN ()` clause. * Add the `query-server` module, so the native query APIs can have their own port, apart from the ports agents report to. Set `SW_QUERY_SERVER_REST_PORT` to a port greater than 0, and GraphQL (`/graphql`), the AI agent conversation view and files (`/ai-agent/conversations/*`), and `/status/config/ttl` move from the core REST port (default `12800`) to it, with their own host, context path and TLS settings (`SW_QUERY_SERVER_REST_*`). Point the UI's `queryUrl`, `swctl --base-url` and other GraphQL clients at the new port. With the default `0`, nothing changes. Together with `receiver-sharing-server`, no agent or query traffic is left on the core ports. #### UI diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAO.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAO.java index 3eeea047e285..2fb99095ed59 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAO.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAO.java @@ -255,6 +255,9 @@ public List queryByTraceId(String traceId, @Nullable Duration dur @SneakyThrows @Override public List queryBySegmentIdList(List segmentIdList, @Nullable Duration duration) throws IOException { + if (CollectionUtils.isEmpty(segmentIdList)) { + return Collections.emptyList(); + } final var tables = tableHelper.getTablesWithinTTL(SegmentRecord.INDEX_NAME); final var segmentRecords = new ArrayList(); final ArrayList conditions = new ArrayList<>(); diff --git a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAOTest.java b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAOTest.java index 01e5131e26d8..83185e38cfe4 100644 --- a/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAOTest.java +++ b/oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCTraceQueryDAOTest.java @@ -39,6 +39,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.verifyNoInteractions; import static org.mockito.Mockito.when; @ExtendWith(MockitoExtension.class) @@ -100,6 +101,16 @@ void queryBySegmentIdList_shouldUseInClause() throws Exception { assertThat(sql).doesNotContain(" or "); } + @Test + void queryBySegmentIdList_withEmptyList_shouldReturnEmptyWithoutQuerying() throws Exception { + when(tableHelper.getTablesWithinTTL(SegmentRecord.INDEX_NAME)) + .thenReturn(Collections.singletonList(TABLE)); + + assertThat(dao.queryBySegmentIdList(Collections.emptyList(), null)).isEmpty(); + + verifyNoInteractions(jdbcClient); + } + @Test void queryByTraceIdWithInstanceId_shouldProduceValidSqlWithBothInClauses() throws Exception { when(tableHelper.getTablesWithinTTL(SegmentRecord.INDEX_NAME))