@@ -31,7 +31,7 @@ namespace baikaldb {
31
31
DEFINE_int64 (retry_interval_us, 500 * 1000 , " retry interval " );
32
32
DEFINE_int32 (single_store_concurrency, 20 , " max request for one store" );
33
33
DEFINE_int64 (max_select_rows, 10000000 , " query will be fail when select too much rows" );
34
- DEFINE_int64 (max_affected_rows, 10000000 , " query will be fail when select too much rows" );
34
+ DEFINE_int64 (max_affected_rows, 10000000 , " query will be fail when affect too much rows" );
35
35
DEFINE_int64 (print_time_us, 10000 , " print log when time_cost > print_time_us(us)" );
36
36
DEFINE_int64 (baikaldb_alive_time_s, 10 * 60 , " obervation time length in baikaldb, default:10 min" );
37
37
BRPC_VALIDATE_GFLAG (print_time_us, brpc::NonNegativeInteger);
@@ -828,7 +828,8 @@ ErrorType OnRPCDone::handle_response(const std::string& remote_side) {
828
828
if (_op_type != pb::OP_SELECT && _op_type != pb::OP_SELECT_FOR_UPDATE && _op_type != pb::OP_ROLLBACK) {
829
829
_fetcher_store->affected_rows += _response.affected_rows ();
830
830
_client_conn->txn_affected_rows += _response.affected_rows ();
831
- if (_client_conn->txn_affected_rows > FLAGS_max_affected_rows) {
831
+ // 事务限制affected_rows,非事务限制会导致部分成功
832
+ if (_client_conn->txn_affected_rows > FLAGS_max_affected_rows && _state->txn_id != 0 ) {
832
833
DB_DONE (FATAL, " _affected_row:%ld > %ld FLAGS_max_affected_rows" ,
833
834
_client_conn->txn_affected_rows .load (), FLAGS_max_affected_rows);
834
835
return E_BIG_SQL;
@@ -1025,39 +1026,37 @@ ErrorType FetcherStore::process_binlog_start(RuntimeState* state, pb::OpType op_
1025
1026
if (need_process_binlog (state, op_type)) {
1026
1027
auto binlog_ctx = client_conn->get_binlog_ctx ();
1027
1028
uint64_t log_id = state->log_id ();
1028
- if (op_type == pb::OP_PREPARE || binlog_prepare_success) {
1029
- binlog_cond.increase ();
1030
- auto write_binlog_func = [this , state, binlog_ctx, op_type, log_id]() {
1031
- ON_SCOPE_EXIT ([this ]() {
1032
- binlog_cond.decrease_signal ();
1033
- });
1034
- if (op_type == pb::OP_PREPARE) {
1035
- int64_t timestamp = TsoFetcher::get_instance ()->get_tso (binlog_ctx->tso_count ());
1036
- if (timestamp < 0 ) {
1037
- DB_WARNING (" get tso failed log_id: %lu txn_id:%lu op_type:%s" , log_id, state->txn_id ,
1038
- pb::OpType_Name (op_type).c_str ());
1039
- error = E_FATAL;
1040
- return ;
1041
- }
1042
- write_binlog_param.txn_id = state->txn_id ;
1043
- write_binlog_param.log_id = log_id;
1044
- write_binlog_param.primary_region_id = client_conn->primary_region_id ;
1045
- write_binlog_param.global_conn_id = client_conn->get_global_conn_id ();
1046
- write_binlog_param.username = client_conn->user_info ->username ;
1047
- write_binlog_param.ip = client_conn->ip ;
1048
- write_binlog_param.client_conn = client_conn;
1049
- write_binlog_param.fetcher_store = this ;
1050
- binlog_ctx->set_start_ts (timestamp);
1051
- }
1052
- write_binlog_param.op_type = op_type;
1053
- auto ret = binlog_ctx->write_binlog (&write_binlog_param);
1054
- if (ret != E_OK) {
1029
+ binlog_cond.increase ();
1030
+ auto write_binlog_func = [this , state, binlog_ctx, op_type, log_id]() {
1031
+ ON_SCOPE_EXIT ([this ]() {
1032
+ binlog_cond.decrease_signal ();
1033
+ });
1034
+ if (op_type == pb::OP_PREPARE) {
1035
+ int64_t timestamp = TsoFetcher::get_instance ()->get_tso (binlog_ctx->tso_count ());
1036
+ if (timestamp < 0 ) {
1037
+ DB_WARNING (" get tso failed log_id: %lu txn_id:%lu op_type:%s" , log_id, state->txn_id ,
1038
+ pb::OpType_Name (op_type).c_str ());
1055
1039
error = E_FATAL;
1040
+ return ;
1056
1041
}
1057
- };
1058
- Bthread bth (&BTHREAD_ATTR_SMALL);
1059
- bth.run (write_binlog_func);
1060
- }
1042
+ write_binlog_param.txn_id = state->txn_id ;
1043
+ write_binlog_param.log_id = log_id;
1044
+ write_binlog_param.primary_region_id = client_conn->primary_region_id ;
1045
+ write_binlog_param.global_conn_id = client_conn->get_global_conn_id ();
1046
+ write_binlog_param.username = client_conn->user_info ->username ;
1047
+ write_binlog_param.ip = client_conn->ip ;
1048
+ write_binlog_param.client_conn = client_conn;
1049
+ write_binlog_param.fetcher_store = this ;
1050
+ binlog_ctx->set_start_ts (timestamp);
1051
+ }
1052
+ write_binlog_param.op_type = op_type;
1053
+ auto ret = binlog_ctx->write_binlog (&write_binlog_param);
1054
+ if (ret != E_OK) {
1055
+ error = E_FATAL;
1056
+ }
1057
+ };
1058
+ Bthread bth (&BTHREAD_ATTR_SMALL);
1059
+ bth.run (write_binlog_func);
1061
1060
return E_OK;
1062
1061
}
1063
1062
return E_OK;
0 commit comments