Repository navigation
[development]: Changes for polling result status and skeletons for chunk downloader - #4
Conversation
| this.workspaceClient = new WorkspaceClient(databricksConfig); | ||
| } | ||
|
|
||
| @VisibleForTesting |
There was a problem hiding this comment.
This is already a public method, you don't need VisibleForTesting.
| handleFailedExecution(responseState, statementId); | ||
|
|
||
| // TODO: Add timeout | ||
| while (responseState.equals(StatementState.PENDING) || responseState.equals(StatementState.RUNNING)) { |
| } | ||
| } | ||
| // should not reach here, add better handling | ||
| throw new RuntimeException("Unreachable code"); |
There was a problem hiding this comment.
The code structure here is confusing. Can you consider this flow?
executeStatement();
while (RUNNING || PENDING) {
Sleep();
GetResponse();
}
if (!SUCCESS) {
handleErrors(); // this will throw exception.
}
return successResults;
There was a problem hiding this comment.
Thanks for suggestion. This indeed looks cleaner.
There was a problem hiding this comment.
I think this file's changes are not pushed to the head yet?
There was a problem hiding this comment.
It is, I can see the uploaded changes. There are 4 commits in the PR now.
| workspaceClient.statementExecution().closeStatement(statementId); | ||
| } | ||
|
|
||
| private void handleFailedExecution(StatementState statementState, String statementId) throws SQLException { |
There was a problem hiding this comment.
Given the method's name, I almost think you should assert that the input is an error case.
There was a problem hiding this comment.
Added exception for other cases
| * </ul> | ||
| * -> | ||
| */ | ||
| enum DownloadStatus { |
There was a problem hiding this comment.
Usually you would have a NONE or UNKNOWN as a default value in the enum.
| } | ||
|
|
||
| void setChunkUrl(String chunkUrl) { | ||
| this.chunkUrl = chunkUrl; |
There was a problem hiding this comment.
What is the relationship between the new URL (chunk) and chunkIndex, numberRows, rowOffset etc? Do you need to reset all or part of the state?
There was a problem hiding this comment.
I may understand setter on status but I do not understand why chunkUrl can be set.
There was a problem hiding this comment.
So, few things I will get from resultManifest: chunk index, rowOffset, numberOfRows and bytes. But next index, url, expiry would be fetched from GetResultData API which would take next-chunk-index and statement-Id as parameters.
The first chunk url will be part of statement response, for others we need to fetch each one by one, and then set the chunk Url. The chunk downloader will then download chunks in parallel based on number of threads, buffer memory size and if chunk url is available.
I will add these changes in separate PR.
|
|
||
| private final long totalRows; | ||
| private final long totalChunks; | ||
| private final ImmutableMap<Long, ChunkInfo> rowOffsetToChunkMap; |
There was a problem hiding this comment.
Chunk info is self contained. Why do you need a Map? When you have a map, do you have to deal with the exposure such as duplicate chunks or missing chunks? I do not see the use or validation logic around the chunk indice.
There was a problem hiding this comment.
Basically, this map is in ArrowStreamResult class, which is main handler for ArrowStream based results. Now based on current row index, it can return exact chunk-index, which can be used for reading current row data. Chunk downloader also has a map, which maps to chunk index to arrow result (including data). So, using together both of these maps, I can reach to exact chunk, and then read exact row from that chunk.
In this map, the data is populated from manifest, and not actual result data, thus there won't be missing chunks, since these are metadata.
I will send more changes in separate PR.
| * @param chunkIndex index of chunk | ||
| * @return the chunk at given index | ||
| */ | ||
| public ArrowResultChunk getChunk(int chunkIndex) { |
There was a problem hiding this comment.
Do you need to keep track of the chunks or you can rely on the server?
There was a problem hiding this comment.
I will have multiple chunks pre-downloaded based on buffer size, and once a chunk is consumed, I will free that from memory, and download the next one. So, we will keep track of chunks which are already downloaded (or freed or yet to be downloaded).
There was a problem hiding this comment.
Did we chat about this today that you just need a simple throughput controller by size of the thread pool?
The chunk sizes are predictable by the server. It's how it decides how many chunks you would end up getting.
There was a problem hiding this comment.
Yes, we will control it by allowed number of chunks to be downloaded which will eventually be controlled by number of worker threads. Chunk size will be ignored for now.
| StatementStatus responseStatus = response.getStatus(); | ||
| ResultManifest resultManifest = | ||
| responseStatus.getState() == StatementState.SUCCEEDED ? response.getManifest() : null; | ||
| ResultData resultData = responseStatus.getState() == StatementState.SUCCEEDED ? response.getResult() : null; |
There was a problem hiding this comment.
I now realize you could get results from ExecuteStatementResponse or GetStatementResponse which do not share the same interface. If you convert ExecuteStatementResponse to GetStatementResponse, your code would be more compact.
GetStatementResponse getStatementResponse = ... // response.getManifest() + response.getResult()
... remove line 73-75
... reuse getStatementResponse in the loop too.
... remove line 89-92
return new DatabricksResultSet(responseStatus, statementId, getStatementResponse.getResult(),
getStatementResponse.getManifest())
There was a problem hiding this comment.
Yes, converted getResponse as ExecuteResponse, and removed extra code.
Major fixes: - #1: Use 2-thread pool instead of single-thread to prevent one blocked heartbeat RPC from starving others on the same connection - #3: Fix getStoppedFlag() leak — use get() + ALREADY_STOPPED sentinel instead of computeIfAbsent() which re-created a false flag after stopHeartbeat() removed it, causing RPCs after stop Minor fixes: - #2: Increase awaitTermination from 5s to 10s with explanatory comment - #4: Add comment about client capture retaining session reference - #5: Document reactive vs proactive heartbeat stop limitation - #6, #7, #9, #10, #11: Acknowledged as correct/acceptable per reviewer Co-authored-by: Isaac Signed-off-by: Gopal Lal <[email protected]>
Removes the OWASP step, NVD database cache, and OWASP findings parsing
from securityScan.yml. OSV-Scanner now drives the gate alone.
Motivation:
- OSV's database is a strict superset of NVD's (federates GHSA, NVD,
PyPA, RustSec, Go vuln DB). We've already seen two real CVEs OSV
catches that OWASP misses entirely -- CVE-2025-66566 in lz4 and
CVE-2026-5598 in bouncycastle, both GHSA-only with no NVD CPE.
- The release pipeline at databricks/secure-public-registry-releases-eng
already skips OWASP (every Maven step has -Ddependency-check.skip=true)
and runs its own artifact-level scan via databricks/gh-action-scan.
So removing OWASP from this repo's CI does not disturb release gating.
- OWASP's NVD database (~150-700 MB), the NVD_API_KEY secret, and the
cache machinery added minutes per run for coverage we don't actually
use any more.
The OWASP plugin block stays in jdbc-core/pom.xml and owasp-suppressions.xml
stays in the repo, because the disabled-anyway in-repo release.yml /
release-thin.yml workflows still reference them. Cleaning those up is a
separate change.
Also addresses these from the PR review:
#1 (SBOM existence guard): the OSV step now explicitly checks
target/bom.json exists before scanning, and that osv-scanner
produced a non-empty output. Build failures now surface with a
clear ::error:: instead of a downstream jq error.
#3 (set -uo pipefail without -e): added a comment explaining that -e
is dropped intentionally because osv-scanner exits 1 on any
finding regardless of severity; the severity >= 7 filter below is
the real gate.
#4 (severity filter silently treats malformed scores as 0): the
Collect findings step now logs total_findings alongside
high_count, so a mismatch (e.g. "10 total / 0 high") would be
visible in the step summary and warn ops about OSV format drift.
#5 (suppressions are CVE-id global, not package-scoped): OSV-Scanner
v2.3.8 does not actually support per-package CVE-id ignores
(verified against internal/config/config.go -- PackageOverrides
has no per-CVE field). Documented the trade-off explicitly in
osv-scanner.toml's header so future readers understand the
scoping model and the acceptable-risk reasoning.
#7 (fork PR maven config): added a comment in the workflow explaining
that fork PRs work even with JFrog OIDC skipped, because all of
the driver's direct dependencies are published to public Maven
Central. JFrog is just a mirror, not a source.
Verified locally: OSV reports the same 2 unsuppressed CVSS>=7 findings
(bouncycastle CVE-2026-5598 + libthrift cluster) as before, with no
schema errors against the corrected osv-scanner.toml.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <[email protected]>
Removes the OWASP step, NVD database cache, and OWASP findings parsing
from securityScan.yml. OSV-Scanner now drives the gate alone.
Motivation:
- OSV's database is a strict superset of NVD's (federates GHSA, NVD,
PyPA, RustSec, Go vuln DB). We've already seen two real CVEs OSV
catches that OWASP misses entirely -- CVE-2025-66566 in lz4 and
CVE-2026-5598 in bouncycastle, both GHSA-only with no NVD CPE.
- The release pipeline at databricks/secure-public-registry-releases-eng
already skips OWASP (every Maven step has -Ddependency-check.skip=true)
and runs its own artifact-level scan via databricks/gh-action-scan.
So removing OWASP from this repo's CI does not disturb release gating.
- OWASP's NVD database (~150-700 MB), the NVD_API_KEY secret, and the
cache machinery added minutes per run for coverage we don't actually
use any more.
The OWASP plugin block stays in jdbc-core/pom.xml and owasp-suppressions.xml
stays in the repo, because the disabled-anyway in-repo release.yml /
release-thin.yml workflows still reference them. Cleaning those up is a
separate change.
Also addresses these from the PR review:
#1 (SBOM existence guard): the OSV step now explicitly checks
target/bom.json exists before scanning, and that osv-scanner
produced a non-empty output. Build failures now surface with a
clear ::error:: instead of a downstream jq error.
#3 (set -uo pipefail without -e): added a comment explaining that -e
is dropped intentionally because osv-scanner exits 1 on any
finding regardless of severity; the severity >= 7 filter below is
the real gate.
#4 (severity filter silently treats malformed scores as 0): the
Collect findings step now logs total_findings alongside
high_count, so a mismatch (e.g. "10 total / 0 high") would be
visible in the step summary and warn ops about OSV format drift.
#5 (suppressions are CVE-id global, not package-scoped): OSV-Scanner
v2.3.8 does not actually support per-package CVE-id ignores
(verified against internal/config/config.go -- PackageOverrides
has no per-CVE field). Documented the trade-off explicitly in
osv-scanner.toml's header so future readers understand the
scoping model and the acceptable-risk reasoning.
#7 (fork PR maven config): added a comment in the workflow explaining
that fork PRs work even with JFrog OIDC skipped, because all of
the driver's direct dependencies are published to public Maven
Central. JFrog is just a mirror, not a source.
Verified locally: OSV reports the same 2 unsuppressed CVSS>=7 findings
(bouncycastle CVE-2026-5598 + libthrift cluster) as before, with no
schema errors against the corrected osv-scanner.toml.
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <[email protected]>
Adding changes to poll the statement execution result, and wrap the result in a DatabricksResultSet instance. Also adding changes to define skeletons for ArrowChunk result and chunk downloader class.