Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

mergeMigration #32496

Merged
merged 11 commits into from
Jan 26, 2023
Merged

mergeMigration #32496

merged 11 commits into from
Jan 26, 2023

Conversation

xinlian12
Copy link
Member

@xinlian12 xinlian12 commented Dec 7, 2022

Issue

This change is part of the feature work #32131. In order to support merge (which requires the epk version leases) and align with changeFeedProcessor long term strategy, we introduced a new API handleLatestVersionChanges.

When customer switch from handleChanges to handleLatestChanges, due to the internal lease store switch, if there is no any support, then the changeFeed processing will start from beginning, which could cause high amount duplicate processing, which is not ideal.

Solution

In order to minimize the impact when customer switch API, we added automatic migration support in this PR.

  • If a pkRangeId version lease store is detected, then SDK is going to bootstrap based on the existed pkRangeId version lease store. At the end of the bootstrap, it will also delete all previous pkRangeId version leases, which will be used as a signal to coordinate with changeFeedProcessorInstance still use handleChanges API.
  • If a pkRangeId version lease store does not exists, then SDK is going to bootstrap from scratch, but it will also initialize an empty pkRangeId version lease store at the same time to prevent it is being initialized again in the future.

##Previous Main Flow

  graph TD
  A[Initialize] --> B{Is lease store initialized?}
  B -- Yes --> C[Finish]
  B -- No -->  D[Acquire Lock]
  D --> E[Create epk version leases from pkRanges]
  E --> F[Mark epk version lease store initialized]
  F --> G[Release epk version lease store lock]
  G --> C
Loading

##Current Main Flow

 graph TD
A[Initialize] --> B{Is epk version lease store initialized?}
B -- Yes --> C[Finish]
B -- No -->  D[Acquire Lock]
D --> E{Is PkRangeId Version lease store initialized?}
E -- YES --> F[Get all pkRangeId version leases]
F --> G[Create epk version leases from pkRangeId version leases]
G --> H[Mark epk version lease store initialized]
H --> I[Delete all pkRangeId version leases]
I --> J[Release epk version lease store lock]
J --> C
E -- NO --> K[Acquire pkRangeId version lease store lock]
K --> L[Create epk version leases from pkRanges]
L --> M[Mark epk version lease store initialized]
M --> N[Mark pkRangeId version lease store initialized]
N --> O[Release epk version lease store lock]
O --> P[Release pkRangeId version lease store lock]
P --> C

Loading

image

@ghost ghost added the Cosmos label Dec 7, 2022
@azure-sdk
Copy link
Collaborator

API change check

API changes are not detected in this pull request.

@xinlian12
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@FabianMeiswinkel FabianMeiswinkel left a comment

Choose a reason for hiding this comment

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

Thanks - looks great!

@xinlian12
Copy link
Member Author

/azp run java - cosmos - tests

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@xinlian12
Copy link
Member Author

Tested the following failed tests locally
readMyWrites
before_OrderbyDocumentQueryTest

@xinlian12
Copy link
Member Author

/check-enforcer override

@xinlian12 xinlian12 merged commit 3788573 into Azure:main Jan 26, 2023
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.

None yet

3 participants