From 069239dce83498293e86851d37ad5943b5d919da Mon Sep 17 00:00:00 2001 From: danieljbruce Date: Mon, 22 Jul 2024 09:45:47 -0400 Subject: [PATCH 1/2] fix: throw away excess data in order to avoid delivering duplicate data (#1453) * Do not pass duplicated data along to the user * Skip the two tests for now * Fix the mock on the row function * Remove only handlers * Remove console logs and other mock inspections * Remove import * Split the if blocks up and add a comment * Update the comment --- src/table.ts | 13 +++++++++++++ test/table.ts | 9 +++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) 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<{}>, From ed942c553f717d3734624b8877ee08d8eb425a46 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:11:31 -0400 Subject: [PATCH 2/2] chore(main): release 5.1.2 (#1455) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> --- CHANGELOG.md | 7 +++++++ package.json | 2 +- samples/package.json | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) 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" },