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

feature: support tcc mode distributed transaction #12

Closed
dk-lockdown opened this issue Apr 26, 2022 · 1 comment
Closed

feature: support tcc mode distributed transaction #12

dk-lockdown opened this issue Apr 26, 2022 · 1 comment
Assignees

Comments

@dk-lockdown
Copy link
Collaborator

Describe the solution you'd like
There is a DistributedTransactionManager

func (manager *DistributedTransactionManager) branchCommit(bs *api.BranchSession) (api.BranchSession_BranchStatus, error) {
	db := resource.GetDBManager().GetDB(bs.ResourceID)
	if db == nil {
		return 0, fmt.Errorf("DB resource is not exist, db name: %s", bs.ResourceID)
	}

	if err := GetUndoLogManager().DeleteUndoLogByXID(db, bs.XID); err != nil {
		return api.PhaseTwoCommitting, err
	}
	if err := manager.storageDriver.DeleteBranchSession(context.Background(), bs.BranchID); err != nil {
		log.Error(err)
	}
	log.Debugf("branch session committed, branch id: %s, lock key: %s", bs.BranchID, bs.LockKey)
	return api.Complete, nil
}

When calling branchCommit method, should judge the type of BranchSession, if the branch type is api.TCC, should send http request to CommitRequestPath, the CommitRequestPath is serialized into ApplicationData of BranchSession.

When calling branchRollback should to the same thing as above.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@bohehe
Copy link
Collaborator

bohehe commented May 4, 2022

Please assign to me. I'd like to have a try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants