[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-15 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-483131174
 
 
   单测都挂掉了。


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-07 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480675997
 
 
   > 我考虑了一下,事务放在一次rpc里面可能支持的不够完善。比如这样的场景: 这个事务有两个操作,(1)查询记录1(2)根据1的查询结果,修改记录2。
   > 这种情景,用户可以根据一个事务的前几个语句对该事务后边的操作做一些逻辑判断,所以前边的结果得在事务结束前需要返回给用户。
   
   如果commands之间的代码介入不可避免,我觉得也ok,但是这里的使用要更加直觉化一些。一种方案如下:
   ```
   auto tx = brpc::NewMysqlTransaction(...);  // args can be replaced with 
MysqlTransactionOptions to apply more configurations.
   ...
   brpc::MysqlRequest crudReq(tx);  // the request is bound to `tx'
   brpc::MysqlResponse curdRsp;
   brpc::Controller crudCntl;
   crudReq.Query("...sql statement...");
   channel.CallMethod(NULL, &crudCntl, &crudReq, &curdRsp, NULL);
   ...
   delete tx;  // calls tx->End() automatically, or user can call tx->End() 
manually and delete tx later.
   ```


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-04-04 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-480129822
 
 
   > @jamesge 最近在考虑prepared statement 和 
transaction的实现问题。这两个功能的特点是,需要在一个连接上面进行多次回话,在多次回话过程中连接需要独占。
   > 调用接口的伪代码:
   > // begin transaction
   > brpc::MysqlRequest txReq;
   > brpc::MysqlResponse txRsp;
   > brpc::Controller txCntl;
   > txCntl.txState = BEGIN_TX;
   > txReq.BeginTx();
   > channel.CallMethod(NULL, &txCntl, &txReq, &txRsp, NULL);
   > 
   > const brpc::MysqlReply::Tx& tx = txRsp.reply(0).tx();
   > 
   > //txRsp keep a connection
   > // begin crud operation
   > brpc::MysqlRequest crudReq1;
   > brpc::MysqlResponse curdRsp1;
   > brpc::Controller crudCntl1;
   > crudCntl1.tx = tx;
   > txReq1.Query("sql statement1");
   > channel.CallMethod(NULL, &crudCntl1, &crudReq1, &crudRsp1, NULL);
   > 
   > brpc::MysqlRequest crudReq2;
   > brpc::MysqlResponse curdRsp2;
   > brpc::Controller crudCntl2;
   > crudCntl2.tx = tx;
   > txReq1.Query("sql statement2");
   > channel.CallMethod(NULL, &crudCntl2, &crudReq2, &curdRsp2, NULL);
   > // end crud operation
   > 
   > // commit transaction
   > // after that release the connect to pool
   > brpc::MysqlRequest commitReq;
   > brpc::MysqlResponse commitRsp;
   > brpc::Controller commitCntl;
   > commitCntl.tx = tx;
   > commitCntl.txState = END_TX;
   > commitReq.Commit();
   > channel.CallMethod(NULL, &commitCntl, &commitReq, &commitRsp, NULL);
   > 
   > 需要对代码修改的地方有
   > 
1、在开始事务的controller里面设置一个标识,这样在它的OnComplete调用的时候,不释放连接到pool里面,返回的接口里面包含事务的信息。
   > 
2、后续的crud的controller里面设置事务的信息,在IssueRPC的时候,lb和选择连接的地方,可以根据是否设置事务做分支处理,主要是在选择连接的地方。
   > 3、在结束事务的controller里面设置一个标识,这样它在OnComplete的时候会释放连接。
   > 
   > prepared statement和这个类似。
   > 
   > 事务和prepared 
statement的处理流程在所有关系型数据库都类似,也可以抽象出来一些公共的内容。我参考了golang的database/sql库
   > 
   > 以上请戈君评审一下,看有什么建议。
   
   
实现上需要多次交互,并不意味着用户一定要感知到多次交互,本质上一个tx对用户也是一件事(要么成功要么失败),一个tx里的所有请求能否让用户一次性输入?即用户调用request中的BeginTx/Query/EndTx等接口可以编排一次tx,然后再CallMethod。


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-03-22 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-475585775
 
 
   > 
如果有人错误的在单个命令里面写了两个命令,那么在response的处理里面做一个校验,判断返回的reply个数大于我们request时候预期的,就报错关闭连接。
   
   
这个必要性不大,反而会让用户觉得麻烦。比如从配置中读进来代表commands的字段可能包含多个command,用户还得拆开一个个调用。既然本身就支持简单的分隔,就没必要人为的拆开了。


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-03-21 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-475487813
 
 
   
如果不允许single的话,就不需要pipelined_count那套了。发送和之前可以完全一致,不需要区分command和commands,收response靠more_results判断是否收完了,如果一个连接上有不符合预期的数据(比如more_results为false之后,source还没有空之类的)可以考虑关闭连接。


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-03-20 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-474786548
 
 
   > 
对,现在一个request里面可以写多个命令,用逗号分割,一个request对应一个response,response里面会有多个reply,每个reply对应一个命令的结果。现在的问题是连接在single模式下,多线程读取消息可能错乱。这个是需要修改的。如果以后要是支持事务和prepared
 statement的话,那么一个连接就需要被独占,因为这个连接需要支持事务的多次访问,这种情况下,我觉得不能使用单链接模式了。你看应该如何选择。
   
   
连接模式是可以限定为pooled|short的,以确保response和request的对应关系。因为一般来说,连接数对mysql是个很重要的指标,mysql的线程模型也很落后,即使真地single连上去,server端未必能很好地应对。另外is_multi这个名字是不准确的,应该叫more_results吧?


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org



[GitHub] [incubator-brpc] jamesge commented on issue #692: Add Mysql Protocol, only support text protocol now, not support trans…

2019-03-20 Thread GitBox
jamesge commented on issue #692: Add Mysql Protocol, only support text protocol 
now, not support trans…
URL: https://github.com/apache/incubator-brpc/pull/692#issuecomment-474713864
 
 
   这里的基本问题还是mysql中response是怎么和request对上的, 
如果有id,那就是通过correlation_id机制;如果是靠server端保证对一个request一定会回一个response(类似redis),那就要设置正确的pipelined_count


This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

-
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org