Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: throw away excess data in order to avoid delivering duplicate data #1453

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,19 @@
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);
Expand Down Expand Up @@ -817,7 +830,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 833 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 833 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down Expand Up @@ -975,7 +988,7 @@
userStream.emit('error', error);
}
})
.on('data', _ => {

Check warning on line 991 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used
// Reset error count after a successful read so the backoff
// time won't keep increasing when as stream had multiple errors
numConsecutiveErrors = 0;
Expand Down Expand Up @@ -1598,7 +1611,7 @@
// Handling retries in this client. Specify the retry options to
// make sure nothing is retried in retry-request.
noResponseRetries: 0,
shouldRetryFn: (_: any) => {

Check warning on line 1614 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

'_' is defined but never used

Check warning on line 1614 in src/table.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
return false;
},
};
Expand Down
9 changes: 7 additions & 2 deletions test/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<{}>,
Expand Down
Loading