Skip to content

Bigtable - issue with table.exists when creating a table then adding a family #1451

@dom-white

Description

@dom-white

Hi, it's great to see the new Bigtable functionality added, but I am having an issue checking and creating tables.

I can successfully use table.create() and then call table.createFamily() from it's callback function, but I get an error on creation of the 'family' if I have just happened to test whether the table exists first.

Environment details

  • OS: Ubuntu 16.04
  • Node.js version: v6.1.0
  • npm version: 3.8.6
  • gcloud-node version: v0.37.0

Steps to reproduce

var table = bigtable.table('prezzy');

table.exists(function(err, exists) {
    if (exists) {
        console.log("Table already exists");
    } else {
        table.create(function(err, table, apiResponse) {
            if (err) {
                console.log("Error from table.create(): " + err);
            } else {
                console.log("Table created, now create family");

                table.createFamily('follows', function(err, family) {
                    if (err) {
                        console.log("Error from table.createFamily(): " + err);
                    } else {
                        console.log("family created");
                    }
                });
            }
        });
    }
});

In this case I get

Table created, now create family
Error from table.createFamily(): Error: Failed to read: projects/{12345678}/instances//clusters/my-cluster/tables/prezzy

If I simply remove the 'exists' test it works (obviously if the table does not exist. I am deleting the table between the tests)

var table = bigtable.table('prezzy');

table.create(function(err, table, apiResponse) {

    if (err) {
        console.log("Error from table.create(): " + err);
    } else {
        console.log("Table created, now create family");

        table.createFamily('follows', function(err, family) {
            if (err) {
                console.log("Error from table.createFamily(): " + err);
            } else {
                console.log("family created");
            }
        });
    }
});

This code produces the expected result

Table created, now create family
family created

It would seem that the use of the 'exists' API call is changing the nature of the 'table' object

Metadata

Metadata

Assignees

Labels

api: bigtableIssues related to the Bigtable API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions