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

reactor:multiple update executor #481

Merged
merged 16 commits into from
Feb 20, 2023
Merged

Conversation

VaderKai
Copy link
Contributor

What this PR does:
refactor pkg/datasource/sql/undo/builder to pkg/datasource/sql/exec/at

Which issue(s) this PR fixes:

Fixes #439

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@luky116
Copy link
Contributor

luky116 commented Feb 14, 2023

在seata-go-sample项目中跑通了,再提交,这样能避免很多问题

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After running through the seata-go-sample project, submit it again, which can avoid many problems

@VaderKai
Copy link
Contributor Author

在seata-go-sample项目中跑通了,再提交,这样能避免很多问题

好嘞,我下次注意下哈哈

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After running through the seata-go-sample project, submit it again, which can avoid many problems

Alright, I'll pay attention next time haha

@luky116
Copy link
Contributor

luky116 commented Feb 15, 2023

在seata-go-sample项目中跑通了,再提交,这样能避免很多问题

好嘞,我下次注意下哈哈

辛苦大佬哈

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After running through the seata-go-sample project, submit it again, which can avoid many problems

Alright, I'll pay attention next time haha

hard work boss

@luky116
Copy link
Contributor

luky116 commented Feb 15, 2023

在seata-go-sample项目中跑通了,再提交,这样能避免很多问题

好嘞,我下次注意下哈哈

请问大佬大名?

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After running through the seata-go-sample project, submit it again, which can avoid many problems

Alright, I'll pay attention next time haha

May I ask the big guy's name?

@codecov-commenter
Copy link

codecov-commenter commented Feb 15, 2023

Codecov Report

Merging #481 (b495268) into master (cf5661e) will decrease coverage by 0.45%.
The diff coverage is 23.91%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master     #481      +/-   ##
==========================================
- Coverage   39.02%   38.57%   -0.45%     
==========================================
  Files         145      147       +2     
  Lines        9638     9949     +311     
==========================================
+ Hits         3761     3838      +77     
- Misses       5565     5793     +228     
- Partials      312      318       +6     
Impacted Files Coverage Δ
pkg/datasource/sql/exec/at/at_executor.go 0.00% <0.00%> (ø)
pkg/datasource/sql/exec/at/multi_executor.go 0.00% <0.00%> (ø)
pkg/datasource/sql/exec/at/multi_update_excutor.go 32.35% <32.35%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


I'm Weide hahaha

@VaderKai
Copy link
Contributor Author

在seata-go-sample项目中跑通了,再提交,这样能避免很多问题

好嘞,我下次注意下哈哈

请问大佬大名?

我是唯德哈哈哈

@Issues-translate-bot
Copy link

RoBot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


After running through the seata-go-sample project, submit it again, which can avoid many problems

Okay, I'll pay attention next time haha

May I ask the big guy's name?

I'm Weide hahaha

pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor_test.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_update_excutor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_update_excutor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor.go Outdated Show resolved Hide resolved
pkg/datasource/sql/exec/at/multi_executor_test.go Outdated Show resolved Hide resolved
pkg/constant/symbol.go Outdated Show resolved Hide resolved
@luky116
Copy link
Contributor

luky116 commented Feb 18, 2023

跑了下,发现beforeImage和afterImage的值相同
image

{
    "xid":"192.168.51.106:8091:2612448039579227740",
    "branchId":2612448039579227753,
    "sqlUndoLogs":[
        {
            "sqlType":"MULTI",
            "tableName":"order_tbl",
            "beforeImage":{
                "tableName":"order_tbl",
                "sqlType":"MULTI",
                "rows":[
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":1
                            }
                        ]
                    },
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":2
                            }
                        ]
                    }
                ]
            },
            "afterImage":{
                "tableName":"order_tbl",
                "sqlType":"MULTI",
                "rows":[
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":1
                            }
                        ]
                    },
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":2
                            }
                        ]
                    }
                ]
            }
        },
        {
            "sqlType":"MULTI",
            "tableName":"order_tbl",
            "beforeImage":{
                "tableName":"order_tbl",
                "sqlType":"MULTI",
                "rows":[
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":1
                            }
                        ]
                    },
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":2
                            }
                        ]
                    }
                ]
            },
            "afterImage":{
                "tableName":"order_tbl",
                "sqlType":"MULTI",
                "rows":[
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":1
                            }
                        ]
                    },
                    {
                        "fields":[
                            {
                                "keyType":"NULL",
                                "name":"descs",
                                "type":12,
                                "value":"NewDescs-1676710380505"
                            },
                            {
                                "keyType":"PRIMARY_KEY",
                                "name":"id",
                                "type":4,
                                "value":2
                            }
                        ]
                    }
                ]
            }
        }
    ]
}

}

// ExecContext exec SQL, and generate before image and after image
func (m *multiExecutor) ExecContext(ctx context.Context, f exec.CallbackWithNamedValue) (types.ExecResult, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ExecContext 里面,直接判断该使用 MultiUpdateExeCutor 还是使用 MultiDeleteExeCutor,然后直接使用 executor.ExecContext() 方法。下面的beforeImage和afterImage方法就可以用都删了。这里没有逻辑的话,以后应该会更好维护

@luky116 luky116 merged commit 5326e7f into apache:master Feb 20, 2023
@VaderKai VaderKai deleted the feature/multi_update branch February 20, 2023 16:02
georgehao pushed a commit to georgehao/seata-go that referenced this pull request May 7, 2023
* reactor:multiple update executor
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

Successfully merging this pull request may close these issues.

Integrate and test multi update sql
8 participants