Skip to content

Fix missing taskId filter and incorrect IN clause in JDBC profiling query DAOs#13785

Merged
wu-sheng merged 3 commits intoapache:masterfrom
currenjin:fix/jdbc-profiling-query-missing-taskid-filter
Apr 2, 2026
Merged

Fix missing taskId filter and incorrect IN clause in JDBC profiling query DAOs#13785
wu-sheng merged 3 commits intoapache:masterfrom
currenjin:fix/jdbc-profiling-query-missing-taskid-filter

Conversation

@currenjin
Copy link
Copy Markdown
Contributor

@currenjin currenjin commented Apr 2, 2026

Fix missing taskId filter and incorrect IN clause in JDBCJFRDataQueryDAO and JDBCPprofDataQueryDAO

  • Add a unit test to verify that the fix works.
  • Explain briefly why the bug exists and how to fix it.

JDBCJFRDataQueryDAO.getByTaskIdAndInstancesAndEvent and JDBCPprofDataQueryDAO.getByTaskIdAndInstances both had two bugs.

Bug 1 - taskId not used in the WHERE clause

The taskId parameter was null-checked but never added to the SQL query, so all profiling data was returned regardless of which task was requested.

Bug 2 - Incorrect IN clause parameter binding

The instanceIds filter was built as in (?) with a single comma-joined string (e.g. "id1,id2,id3") as the bind parameter. JDBC binds each ? to exactly one value, so the query became WHERE instance_id IN ('id1,id2,id3') - a literal string comparison - which returns no rows when multiple instances are given.

The same pattern was copied from JDBCJFRDataQueryDAO into JDBCPprofDataQueryDAO when pprof support was added (#13502).

Fix

  • Added task_id = ? to the WHERE clause in both DAOs.

  • Replaced the in (?) + joined string with String.join(",", Collections.nCopies(instanceIds.size(), "?")) to generate the correct number of placeholders, matching the pattern used in JDBCEBPFProfilingTaskDAO.

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

  • Update the CHANGES log.

@currenjin currenjin force-pushed the fix/jdbc-profiling-query-missing-taskid-filter branch 2 times, most recently from f7f777b to ba69c5b Compare April 2, 2026 09:26
…uery DAOs

In JDBCJFRDataQueryDAO and JDBCPprofDataQueryDAO, the taskId parameter was
validated but never added to the SQL WHERE clause, causing all profiling data
to be returned regardless of the task. Additionally, the IN clause for
instanceIds used a single comma-joined string parameter instead of individual
bind parameters, which always returned empty results when multiple instances
were specified.
@currenjin currenjin force-pushed the fix/jdbc-profiling-query-missing-taskid-filter branch from 086e432 to b6c1835 Compare April 2, 2026 10:05
@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Apr 2, 2026

CI repies on my manual approval(due to ASF policy and setup).
You are better to run everyone well locally.

@wu-sheng wu-sheng added bug Something isn't working and you are sure it's a bug! backend OAP backend related. labels Apr 2, 2026
@wu-sheng
Copy link
Copy Markdown
Member

wu-sheng commented Apr 2, 2026

And update changes.md.

@wu-sheng wu-sheng added this to the 10.5.0 milestone Apr 2, 2026
@wu-sheng wu-sheng merged commit 9aac830 into apache:master Apr 2, 2026
419 of 421 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend OAP backend related. bug Something isn't working and you are sure it's a bug!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants