Skip to content

[NO REVIEW]fix duplicate records issue#49687

Closed
xinlian12 wants to merge 1 commit into
Azure:mainfrom
xinlian12:spark-read-many-fix
Closed

[NO REVIEW]fix duplicate records issue#49687
xinlian12 wants to merge 1 commit into
Azure:mainfrom
xinlian12:spark-read-many-fix

Conversation

@xinlian12

Copy link
Copy Markdown
Member

No description provided.

Copilot AI review requested due to automatic review settings July 1, 2026 05:35
@xinlian12 xinlian12 requested review from a team and kirankumarkolli as code owners July 1, 2026 05:35
@xinlian12 xinlian12 changed the title fix duplicate records issue [NO REVIEW]fix duplicate records issue Jul 1, 2026
@github-actions github-actions Bot added the Cosmos label Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Cosmos Spark connector’s readManyByPartitionKeys partition iterator to avoid invoking the underlying partition reader after it has already been closed, which can prevent post-close exceptions that may lead to Spark task retries and duplicate output records.

Changes:

  • Added an isClosed guard in hasNext to return false immediately when the iterator/reader has already been closed.
  • Kept the existing “close on completion / close on error / close when exhausted” behavior, but made hasNext safer after closure.
Show a summary per file
File Description
sdk/cosmos/azure-cosmos-spark_3/src/main/scala/com/azure/cosmos/spark/CosmosReadManyByPartitionKeyReader.scala Prevents hasNext from calling into a closed ItemsPartitionReaderWithReadManyByPartitionKey, reducing failures/retries that can cause duplicate records.

Review details

  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Low

Comment on lines +179 to 183
} catch {
case error: Throwable =>
closeReader()
throw error
}
@xinlian12 xinlian12 closed this Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants