beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Yu (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (BEAM-1831) Checking of containment in createdTables may have race condition in StreamingWriteFn
Date Tue, 04 Apr 2017 21:02:41 GMT

     [ 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)

Mime
View raw message