You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Ted Yu (JIRA)" <ji...@apache.org> on 2017/04/04 21:02:41 UTC
[jira] [Updated] (BEAM-1831) Checking of containment in
createdTables may have race condition in StreamingWriteFn
[ https://issues.apache.org/jira/browse/BEAM-1831?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ted Yu updated BEAM-1831:
-------------------------
Description:
{code}
public TableReference getOrCreateTable(BigQueryOptions options, String tableSpec)
throws InterruptedException, IOException {
TableReference tableReference = BigQueryHelpers.parseTableSpec(tableSpec);
if (createDisposition != createDisposition.CREATE_NEVER
&& !createdTables.contains(tableSpec)) {
synchronized (createdTables) {
// Another thread may have succeeded in creating the table in the meanwhile, so
// check again. This check isn't needed for correctness, but we add it to prevent
// every thread from attempting a create and overwhelming our BigQuery quota.
DatasetService datasetService = bqServices.getDatasetService(options);
if (!createdTables.contains(tableSpec)) {
{code}
The first createdTables.contains() check is outside synchronized block.
At least createdTables should be declared volatile for the double checked locking to work.
was:
{code}
public TableReference getOrCreateTable(BigQueryOptions options, String tableSpec)
throws InterruptedException, IOException {
TableReference tableReference = BigQueryHelpers.parseTableSpec(tableSpec);
if (createDisposition != createDisposition.CREATE_NEVER
&& !createdTables.contains(tableSpec)) {
synchronized (createdTables) {
// Another thread may have succeeded in creating the table in the meanwhile, so
// check again. This check isn't needed for correctness, but we add it to prevent
// every thread from attempting a create and overwhelming our BigQuery quota.
DatasetService datasetService = bqServices.getDatasetService(options);
if (!createdTables.contains(tableSpec)) {
{code}
The first createdTables.contains() check is outside synchronized block.
At least createdTables should be declared volatile for the double checked locking to work.
> Checking of containment in createdTables may have race condition in StreamingWriteFn
> ------------------------------------------------------------------------------------
>
> Key: BEAM-1831
> URL: https://issues.apache.org/jira/browse/BEAM-1831
> Project: Beam
> Issue Type: Bug
> Components: sdk-java-gcp
> Reporter: Ted Yu
> Assignee: Davor Bonaci
> Priority: Minor
>
> {code}
> public TableReference getOrCreateTable(BigQueryOptions options, String tableSpec)
> throws InterruptedException, IOException {
> TableReference tableReference = BigQueryHelpers.parseTableSpec(tableSpec);
> if (createDisposition != createDisposition.CREATE_NEVER
> && !createdTables.contains(tableSpec)) {
> synchronized (createdTables) {
> // Another thread may have succeeded in creating the table in the meanwhile, so
> // check again. This check isn't needed for correctness, but we add it to prevent
> // every thread from attempting a create and overwhelming our BigQuery quota.
> DatasetService datasetService = bqServices.getDatasetService(options);
> if (!createdTables.contains(tableSpec)) {
> {code}
> The first createdTables.contains() check is outside synchronized block.
> At least createdTables should be declared volatile for the double checked locking to work.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)