You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by "Daniel Halperin (JIRA)" <ji...@apache.org> on 2017/05/18 20:04:04 UTC

[jira] [Closed] (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 ]

Daniel Halperin closed BEAM-1831.
---------------------------------
       Resolution: Not A Bug
    Fix Version/s: Not applicable

> 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: Reuven Lax
>            Priority: Minor
>             Fix For: Not applicable
>
>
> {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)