diff --git a/CHANGELOG.md b/CHANGELOG.md index d0a653a14..7957928f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://www.npmjs.com/package/@google-cloud/bigtable?activeTab=versions +## [5.1.2](https://github.com/googleapis/nodejs-bigtable/compare/v5.1.1...v5.1.2) (2024-07-22) + + +### Bug Fixes + +* Throw away excess data in order to avoid delivering duplicate data ([#1453](https://github.com/googleapis/nodejs-bigtable/issues/1453)) ([069239d](https://github.com/googleapis/nodejs-bigtable/commit/069239dce83498293e86851d37ad5943b5d919da)) + ## [5.1.1](https://github.com/googleapis/nodejs-bigtable/compare/v5.1.0...v5.1.1) (2024-07-11) diff --git a/package.json b/package.json index 970375a2b..c0b1a07e9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@google-cloud/bigtable", - "version": "5.1.1", + "version": "5.1.2", "description": "Cloud Bigtable Client Library for Node.js", "keywords": [ "bigtable", diff --git a/samples/package.json b/samples/package.json index a4e8f6f9a..7c98ce55a 100644 --- a/samples/package.json +++ b/samples/package.json @@ -14,7 +14,7 @@ "node": ">=14.0.0" }, "dependencies": { - "@google-cloud/bigtable": "^5.1.1", + "@google-cloud/bigtable": "^5.1.2", "uuid": "^9.0.0", "yargs": "^16.0.0" }, diff --git a/src/table.ts b/src/table.ts index d484ff649..e7c286c0f 100644 --- a/src/table.ts +++ b/src/table.ts @@ -763,6 +763,19 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`); callback(); return; } + if (TableUtils.lessThanOrEqualTo(row.id, lastRowKey)) { + /* + Sometimes duplicate rows reach this point. To avoid delivering + duplicate rows to the user, rows are thrown away if they don't exceed + the last row key. We can expect each row to reach this point and rows + are delivered in order so if the last row key equals or exceeds the + row id then we know data for this row has already reached this point + and been delivered to the user. In this case we want to throw the row + away and we do not want to deliver this row to the user again. + */ + callback(); + return; + } lastRowKey = row.id; rowsRead++; callback(null, row); diff --git a/test/table.ts b/test/table.ts index 3a33d88d5..f0833ef77 100644 --- a/test/table.ts +++ b/test/table.ts @@ -934,8 +934,13 @@ describe('Bigtable/Table', () => { ]; beforeEach(() => { - sinon.stub(table, 'row').callsFake(() => { - return {} as Row; + sinon.stub(table, 'row').callsFake((...args: unknown[]) => { + return { + id: args[0] as string, + table: table, + bigtable: table.bigtable, + data: {}, + } as Row; }); FakeChunkTransformer.prototype._transform = function ( chunks: Array<{}>,