Skip to content

Fix missing taskId filter in pprof task log query and its DB implementations#13807

Merged
wu-sheng merged 2 commits intoapache:masterfrom
mrproliu:pprof-log-taskid-query
Apr 9, 2026
Merged

Fix missing taskId filter in pprof task log query and its DB implementations#13807
wu-sheng merged 2 commits intoapache:masterfrom
mrproliu:pprof-log-taskid-query

Conversation

@mrproliu
Copy link
Copy Markdown
Contributor

@mrproliu mrproliu commented Apr 9, 2026

  • If this pull request closes/resolves/fixes an existing issue, replace the issue number. Closes #.
  • Update the CHANGES log.

@mrproliu mrproliu added this to the 10.5.0 milestone Apr 9, 2026
@mrproliu mrproliu requested review from Copilot and wu-sheng April 9, 2026 02:24
@mrproliu mrproliu added the enhancement Enhancement on performance or codes label Apr 9, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes pprof task log retrieval to apply the taskId filter at the storage/query layer (rather than querying all logs and filtering in-memory), updating the core DAO contract and the JDBC/Elasticsearch/BanyanDB implementations accordingly.

Changes:

  • Update IPprofTaskLogQueryDAO#getTaskLogList to accept taskId and document the new contract.
  • Push taskId filtering down into JDBC / Elasticsearch / BanyanDB task log queries.
  • Simplify PprofQueryService#queryPprofTaskLogs by removing in-memory filtering and updating CHANGES.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
oap-server/server-storage-plugin/storage-jdbc-hikaricp-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/jdbc/common/dao/JDBCPprofTaskLogQueryDAO.java Add taskId predicate to SQL used to fetch pprof task logs.
oap-server/server-storage-plugin/storage-elasticsearch-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/elasticsearch/query/PprofTaskLogQueryEsDAO.java Add taskId term filter to the ES bool query for pprof task logs.
oap-server/server-storage-plugin/storage-banyandb-plugin/src/main/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/stream/BanyanDBPprofTaskLogQueryDAO.java Add taskId equality condition to BanyanDB stream query.
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/storage/profiling/pprof/IPprofTaskLogQueryDAO.java Change DAO API to require taskId for task log queries.
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/profiling/pprof/PprofQueryService.java Remove in-memory filtering; delegate filtering to DAO and map results.
docs/en/changes/changes.md Document the fix in the 10.5.0 change log.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +28 to +34
* Search task logs by the given task id.
*
* @param taskId the task id to filter by, must not be null or blank
* @return the task logs associated with the given task id
* @throws IOException if the query fails
*/
List<PprofTaskLog> getTaskLogList() throws IOException;
List<PprofTaskLog> getTaskLogList(String taskId) throws IOException;
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Javadoc states taskId must not be null or blank, but there is no validation at the service/DAO boundary. This leads to inconsistent behavior across implementations (e.g., Elasticsearch Query.term throws NPE on null, while JDBC/BanyanDB may silently return empty results). Either enforce this contract (preferred: validate and throw an IllegalArgumentException with a clear message) or relax the Javadoc to match actual behavior.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the checker.

Comment on lines 107 to +110
public List<PprofTaskLog> queryPprofTaskLogs(String taskId) throws IOException {
List<PprofTaskLog> taskLogList = getTaskLogQueryDAO().getTaskLogList();
return findMatchedLogs(taskId, taskLogList);
}

private List<PprofTaskLog> findMatchedLogs(final String taskID, final List<PprofTaskLog> allLogs) {
return allLogs.stream()
.filter(l -> Objects.equals(l.getId(), taskID))
.map(this::extendTaskLog)
.collect(Collectors.toList());
return getTaskLogQueryDAO().getTaskLogList(taskId).stream()
.map(this::extendTaskLog)
.collect(Collectors.toList());
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

taskId is passed directly to the storage layer without validation. Since the Elasticsearch implementation will throw on null (and the DAO Javadoc claims non-null/non-blank), add an explicit check here (or earlier at the GraphQL boundary) to fail fast with a clear error message and consistent behavior across storage backends.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the task id checker in each implementation.

Comment on lines +51 to +58
public List<PprofTaskLog> getTaskLogList(String taskId) throws IOException {
final String index = IndexController.LogicIndicesRegister.getPhysicalTableName(PprofTaskLogRecord.INDEX_NAME);
final BoolQueryBuilder query = Query.bool();
if (IndexController.LogicIndicesRegister.isMergedTable(PprofTaskLogRecord.INDEX_NAME)) {
query.must(Query.term(IndexController.LogicIndicesRegister.RECORD_TABLE_NAME, PprofTaskLogRecord.INDEX_NAME));
}

query.must(Query.term(PprofTaskLogRecord.TASK_ID, taskId));

Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Query.term(..., taskId) requires a non-null value and will throw a NullPointerException if taskId is null. Add an explicit argument validation (or ensure callers validate) so failures are consistent and produce a clearer error than an NPE.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@wu-sheng wu-sheng merged commit 2f03a01 into apache:master Apr 9, 2026
626 of 630 checks passed
@mrproliu mrproliu deleted the pprof-log-taskid-query branch April 9, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Enhancement on performance or codes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants