-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Support Saga Transaction #986
Comments
In the previous description, Sharding-Sphere uses Service Comb Saga's Restful API to implement saga transactions. But SS would like to use saga coordinator in an internal call. |
SS also starts transaction via Saga API https://github.com/apache/incubator-servicecomb-saga/blob/master/docs/api/api.md .
Logic SQLs in a transaction will be parsed and routed, and will be combined into a graph. |
TODO list of saga transaction:
|
What's Saga?
The paper:
https://www.cs.cornell.edu/andru/cs711/2002fa/reading/sagas.pdf
The github project which Sharding-Sphere will integrate with:
https://github.com/apache/incubator-servicecomb-saga
More information from Willem Jiang's presentation:
http://servicecomb.incubator.apache.org/cn/docs/distributed-transactions-saga-implementation/
The second soft transaction (i.e. flexible transaction) which Sharding-Sphere will support is Saga transaction. In the first step, we plan to implement it in Sharding-JDBC.
SS starts a transaction via Saga API(https://github.com/apache/incubator-servicecomb-saga/blob/old-saga/docs/api/api.md). The API looks like this:
{
"policy": "",
"requests": [
{
"id": "",
"type": "",
"serviceName": "",
"parents": [
],
"transaction": {
"method": "",
"path": "",
"params": {
}
},
"compensation": {
"method": "",
"path": "",
"params": {
}
}
}
]
}
Logic SQLs in a SS transaction will be treated as one Saga Request separately. Users of SS should supply the compensatory SQLs correspondingly:
transaction:
INSERT INTO
t_order
(order_id
,user_id
,status
) VALUES (?, '10', 'INIT');compensation:
DELETE FROM
t_order
WHEREorder_id
=?;SS need to implement method of both transaction and compensation for Saga. The path parameter seems to have no use for SS, and should be ignored.
The content of params should include SQL and the parameter of SQL, may implement by currently form parameters.
At last, id and serviceName will be generated by SS uniquely. Saga can use these identifier to find transactions.
The text was updated successfully, but these errors were encountered: