Ted Yu created BEAM-1831: ---------------------------- Summary: 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: runner-dataflow 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)