-
Notifications
You must be signed in to change notification settings - Fork 312
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
fix:dup conflict with balance #1590
Open
ninsmiracle
wants to merge
14
commits into
apache:master
Choose a base branch
from
ninsmiracle:fix_dup_conflict_with_balance
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
fix:dup conflict with balance #1590
ninsmiracle
wants to merge
14
commits into
apache:master
from
ninsmiracle:fix_dup_conflict_with_balance
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acelyc111
reviewed
Jan 30, 2024
// duplication_sync_timer is async with replica close,so replica_duplicator_manager may already | ||
// release | ||
// dup should stop right now | ||
bool replica_is_cloing_or_closed(gpid id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The same to #1608, you can judge the state of the replica by itself.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
#1589
What is changed and how does it work?
There are two conflict may occure when opening duplication and balance:
1.load(one stage of duplication) with replica close
Add a atomic parameter and check replica still have doing log load when it's closed.
So how to end load and let replica close continue?There are two way could make it happen:
-duplication step to next stage(shipping)
-wait duplication do update_duplication_map,and it will
remove_all_duplications
when replica loss primary identity.In remove_all_duplications,duplication will use a map named
_replica
to check the replica identity,so I protected it when replica close.2.gc useless replica with replica close (close one replica twice)
After replica connected with meta, meta will request for config to replica every 500ms. And replica server update itself's config when meta reply.In this logic ,on_node_query_reply_scatter2 will gc useless replica(which status is PS_INACTIVE),to be precise will set status from PS_INACTIVE TO PS_ERROR.
When replica doing
update_local_configuration
,it will exec close action when status changed and new status is PS_INACTIVE or PS_ERROR.So I judge replica is already closed or doing close when replica exec close replica to deal with above problem.
Tests
In summary:
The earliest zlock coredump was caused by the necessity of acquiring a lock during the 'dup' load stage, which requires a lock from a member variable of the 'replica' class. However, at this point, the 'replica' had already been closed, related members are destructedresulting in obtaining,resulting zlock get an error
_lock
value.The root cause of the replica being closed actually stems from the logic where the meta requests 'replica' for configuration, triggering a 'replica gc' process that sets the replica itself to 'PS_ERROR'. Based on the existing logic, both 'PS_INACTIVE' and 'PS_ERROR' trigger the 'begin_close' logic, with 'inactive' having a 10-minute delay and 'error' being executed immediately.
A double safeguard was implemented for the modification. Firstly, when enqueuing the close operation, it is checked whether the replica has already been closed or is in the process of closing. Secondly, during the execution of the close operation, in case it encounters a 'dup load', it is configured to enter the task queue with a delay of one minute.