Skip to content

Commit 00827f2

Browse files
aditishree1Aditishree .
and
Aditishree .
authored
change feed merge fix (Azure#34312)
### Packages impacted by this PR @azure/cosmos ### Issues associated with this PR ### Describe the problem that is addressed by this PR This PR fixes handling of merge error during change feed. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary) Co-authored-by: Aditishree . <[email protected]>
1 parent 1a8397e commit 00827f2

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

sdk/cosmosdb/cosmos/src/client/ChangeFeed/ChangeFeedForEpkRange.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ export class ChangeFeedForEpkRange<T> implements ChangeFeedPullModelIterator<T>
183183
}
184184

185185
// stores the last feedRange for which statusCode is not 304 i.e. there were new changes in that feed range.
186-
let firstNotModifiedFeedRange: [string, string] = undefined;
186+
let firstNotModifiedFeedRange: ChangeFeedRange = undefined;
187187
let result: ChangeFeedIteratorResponse<Array<T & Resource>>;
188188
do {
189189
const [processedFeedRange, response] = await this.fetchNext(diagnosticNode);
@@ -230,7 +230,7 @@ export class ChangeFeedForEpkRange<T> implements ChangeFeedPullModelIterator<T>
230230
*/
231231
private async fetchNext(
232232
diagnosticNode: DiagnosticNodeInternal,
233-
): Promise<[[string, string], ChangeFeedIteratorResponse<Array<T & Resource>>]> {
233+
): Promise<[ChangeFeedRange | undefined, ChangeFeedIteratorResponse<Array<T & Resource>>]> {
234234
const feedRange = this.queue.peek();
235235
if (feedRange) {
236236
// fetch results for feed range at the beginning of the queue.
@@ -252,22 +252,23 @@ export class ChangeFeedForEpkRange<T> implements ChangeFeedPullModelIterator<T>
252252
const continuationValueForFeedRange = result.headers[Constants.HttpHeaders.ETag];
253253
const newFeedRange = this.queue.peek();
254254
newFeedRange.continuationToken = continuationValueForFeedRange;
255-
256-
return [[newFeedRange.minInclusive, newFeedRange.maxExclusive], result];
255+
return [newFeedRange, result];
257256
}
258257
} else {
259-
return [[undefined, undefined], undefined];
258+
return [undefined, undefined];
260259
}
261260
}
262261

263-
private checkedAllFeedRanges(firstNotModifiedFeedRange: [string, string]): boolean {
262+
private checkedAllFeedRanges(firstNotModifiedFeedRange: ChangeFeedRange | undefined): boolean {
264263
if (firstNotModifiedFeedRange === undefined) {
265264
return false;
266265
}
267266
const feedRangeQueueFirstElement = this.queue.peek();
268267
return (
269-
firstNotModifiedFeedRange[0] === feedRangeQueueFirstElement?.minInclusive &&
270-
firstNotModifiedFeedRange[1] === feedRangeQueueFirstElement?.maxExclusive
268+
firstNotModifiedFeedRange.minInclusive === feedRangeQueueFirstElement?.minInclusive &&
269+
firstNotModifiedFeedRange.maxExclusive === feedRangeQueueFirstElement?.maxExclusive &&
270+
firstNotModifiedFeedRange.epkMinHeader === feedRangeQueueFirstElement?.epkMinHeader &&
271+
firstNotModifiedFeedRange.epkMaxHeader === feedRangeQueueFirstElement?.epkMaxHeader
271272
);
272273
}
273274

0 commit comments

Comments
 (0)