Is there a way to patch/increment a Bigtable column value non-integer?

55 Views Asked by At

Using Node.js and the libary: "@google-cloud/bigtable"

I've a scenario where I need to append/increment/patch a text value in a Bigtable row, since we receive multiples requests at the same time, we couldn't afford to use an update function since it would lead to some race condition issues.

The Bigtable does have a function that's similar to what I need, it's the "cell-increment" but it only allows you to use for Integer values, while I need it for strings (Json stringfieds values).

Is there any way to work around this issue handling the concurrent updates safely and without having to restructure a massive database?

Tried to use the increment function, but it only allows for Integer values.

1

There are 1 best solutions below

0
Bora On

You can do a read-modify-write. https://cloud.google.com/bigtable/docs/writes#increments

It should look something like this in node.js

await table.row("my-row-key").createRules({column: 'my-family:my-qualifier', append: 'my-string-suffix'})

https://cloud.google.com/nodejs/docs/reference/bigtable/latest/bigtable/rule

this takes a lock, reads the current value and writes it back with the deltas so another write can't change the value in between causing the problem you mentioned.