Skip to content

[BEAM-12356] Make sure DatasetService is always closed#15480

Merged
reuvenlax merged 2 commits into
apache:masterfrom
reuvenlax:fix-BEAM-12356
Sep 9, 2021
Merged

[BEAM-12356] Make sure DatasetService is always closed#15480
reuvenlax merged 2 commits into
apache:masterfrom
reuvenlax:fix-BEAM-12356

Conversation

@reuvenlax

Copy link
Copy Markdown
Contributor

No description provided.

@reuvenlax

Copy link
Copy Markdown
Contributor Author

R: @jklukas
R: @apilloud

@reuvenlax

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@apilloud apilloud left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

It looks like DatasetService could use some cleanup around exception handling...

BigQueryHelpers.verifyDatasetPresence(datasetService, tempTable);
}
}
} catch (Exception e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do you need this here? Can you catch more specific exceptions?

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.

close() throws Exception, so this is the best I can do.

"Deleting temporary dataset with query results {}", tempTable.getDatasetId());
datasetService.deleteDataset(tempTable.getProjectId(), tempTable.getDatasetId());
}
} catch (Exception e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It doesn't look like this is needed?

if (getWriteDisposition() == BigQueryIO.Write.WriteDisposition.WRITE_EMPTY) {
BigQueryHelpers.verifyTableNotExistOrEmpty(datasetService, table);
}
} catch (Exception e) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not needed?

/** The list of unique ids for each BigQuery table row. */
private transient Map<String, List<String>> uniqueIdsForTableRows;

private @Nullable DatasetService datasetService;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: should this be transient?

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.

done

// shuffling.
private class InsertBatchedElements
extends DoFn<KV<ShardedKey<String>, Iterable<TableRowInfo<ElementT>>>, Void> {
private @Nullable DatasetService datasetService;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: should this be transient?

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.

done

@reuvenlax

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

1 similar comment
@reuvenlax

Copy link
Copy Markdown
Contributor Author

Run Java PreCommit

@lukecwik

lukecwik commented Oct 25, 2021 via email

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants