Repository navigation
bigquery: try getting job if create fails - #2887
Conversation
If we create a job with randomly generated ID, it's highly unlikely that it will with another job created by someone else. When create fails, it is possible that the job was created successfully anyway. Thus, we can be more failure-tolerant by trying to retrieve the job, if create throws. Fixes #2867.
| } | ||
|
|
||
| @Test | ||
| public void testCreateQueryJob() { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
tswast
left a comment
There was a problem hiding this comment.
Thanks! Looking great. A few nits / questions.
| public TableResult query(QueryJobConfiguration configuration, JobOption... options) | ||
| throws InterruptedException, JobException { | ||
| return query(configuration, JobId.of(), options); | ||
| Job.checkNotDryRun(configuration, "query"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| try { | ||
| return getJob(jobInfo.getJobId()); | ||
| } catch (BigQueryException e) { | ||
| System.err.println("rethrow"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| bigqueryRpcMock.create( | ||
| JobInfo.of(LOAD_JOB_CONFIGURATION_WITH_PROJECT).toPb(), EMPTY_RPC_OPTIONS)) | ||
| .andReturn(COMPLETE_LOAD_JOB.toPb()); | ||
| bigqueryRpcMock.create(EasyMock.capture(jobCapture), EasyMock.eq(EMPTY_RPC_OPTIONS))) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| bigquery = options.getService(); | ||
| Job job = bigquery.create(COPY_JOB); | ||
| assertEquals(new Job(bigquery, new JobInfo.BuilderImpl(COMPLETE_COPY_JOB)), job); | ||
| Job job = bigquery.create(QUERY_JOB, JOB_OPTION_FIELDS); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| String selector = (String) capturedOptions.getValue().get(JOB_OPTION_FIELDS.getRpcOption()); | ||
| assertThat(selector.split(",")) | ||
| .asList() | ||
| .containsExactly("jobReference", "configuration", "user_email"); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| new Supplier<JobId>() { | ||
| @Override | ||
| public JobId get() { | ||
| return JobId.of(); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
@tswast PTAL |
tswast
left a comment
There was a problem hiding this comment.
LGTM once Circle is happy
…-plugin to v3.6.0 (#2887) * build(deps): update dependency org.apache.maven.plugins:maven-javadoc-plugin to v3.6.0 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
🤖 I have created a release *beep* *boop* --- ## [6.59.0](https://togithub.com/googleapis/java-spanner/compare/v6.58.0...v6.59.0) (2024-02-15) ### Features * Support public methods to use autogenerated admin clients. ([#2878](https://togithub.com/googleapis/java-spanner/issues/2878)) ([3f71b23](https://togithub.com/googleapis/java-spanner/commit/3f71b23e64bc3a29a29a70db51291b33b67c8f57)) ### Dependencies * Update dependency com.google.cloud:sdk-platform-java-config to v3.25.0 ([#2888](https://togithub.com/googleapis/java-spanner/issues/2888)) ([1c61385](https://togithub.com/googleapis/java-spanner/commit/1c6138520a4070ccb9de95685e338c0b267981a3)) ### Documentation * README for OpenTelemetry metrics and traces ([#2880](https://togithub.com/googleapis/java-spanner/issues/2880)) ([c1d7396](https://togithub.com/googleapis/java-spanner/commit/c1d7396c6f1e0a472b331e319033955c87b81eb8)) * Samples and tests for database Admin APIs. ([#2775](https://togithub.com/googleapis/java-spanner/issues/2775)) ([7c8d869](https://togithub.com/googleapis/java-spanner/commit/7c8d8695c4b6bc4e5034f63fac8681252b9caad0)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
…oogleapis#2887) * refactor: decouple ConsistencyRequest from TableAdminRequestContext This commit updates the internal plumbing for `ConsistencyRequest` and `AwaitConsistencyCallable` to support fully qualified table names without breaking the existing public API for the legacy `BigtableTableAdminClient`. b/502616786 * chore: generate libraries at Wed Apr 15 18:37:03 UTC 2026 * PR feedback * chore: generate libraries at Tue Apr 21 19:06:09 UTC 2026 * chore: generate libraries at Tue Apr 21 19:11:56 UTC 2026 * PR feedback * chore: generate libraries at Wed Apr 22 18:08:03 UTC 2026 --------- Co-authored-by: cloud-java-bot <cloud-java-bot@google.com>
If we create a job with randomly generated ID, it's highly unlikely
that it will with another job created by someone else.
When create fails, it is possible that the job was created successfully
anyway.
Thus, we can be more failure-tolerant by trying to retrieve the job,
if create throws.
Fixes #2867.