【 使用环境 】生产环境 or 测试环境
【 OB 】
【 使用版本 】4.0
【问题描述】只要有begin和commit,中间带多条SQL就是分布式事务吗?看官网不太明白
https://www.oceanbase.com/docs/enterprise-oceanbase-database-cn-10000000000887232
+-------------------------------------------------+
| observer |
+---------------+---------+------+-------+--------+
| ip | version | port | zone | status |
+---------------+---------+------+-------+--------+
| 172.16.11.134 | 4.0.0.0 | 2881 | zone1 | ACTIVE |
| 172.16.11.135 | 4.0.0.0 | 2881 | zone2 | ACTIVE |
| 172.16.11.136 | 4.0.0.0 | 2881 | zone3 | ACTIVE |
+---------------+---------+------+-------+--------+
obclient -h172.16.11.134 -P2881 -uroot -Doceanbase
Connect to obproxy ok
+-------------------------------------------------+
| obproxy |
+---------------+------+-----------------+--------+
| ip | port | prometheus_port | status |
+---------------+------+-----------------+--------+
| 172.16.11.134 | 2883 | 2884 | active |
| 172.16.5.145 | 2883 | 2884 | active |
+---------------+------+-----------------+--------+
obclient -h172.16.11.134 -P2883 -uroot -Doceanbase
表结构如下,未分区:
[root@172-16-11-134 ~]# obclient -h172.16.11.134 -P2883 -uroot@tenant1 -Dtest -A
# 表结构
obclient [test]> show create table sbtest1 \G
*************************** 1. row ***************************
Table: sbtest1
Create Table: CREATE TABLE `sbtest1` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`k` int(11) NOT NULL DEFAULT '0',
`c` char(120) NOT NULL DEFAULT '',
`pad` char(60) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `k_1` (`k`) BLOCK_SIZE 16384 LOCAL
) AUTO_INCREMENT = 1000001 AUTO_INCREMENT_MODE = 'ORDER' DEFAULT CHARSET = utf8mb4 ROW_FORMAT = DYNAMIC COMPRESSION = 'zstd_1.3.8' REPLICA_NUM = 3 BLOCK_SIZE = 16384 USE_BLOOM_FILTER = FALSE TABLET_SIZE = 134217728 PCTFREE = 0
做 oltp_read_only 压测,语句如下:
| BEGIN; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 502016]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 499004]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 505118]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 498083]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 502557]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 467971]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 501913]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 519429]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 501763]; |
| SELECT c FROM sbtest8 WHERE id=? [arguments: 499073];
# 以下4条语句通过 mysqlslap 单独压测,注入前后性能无明显变化
| SELECT c FROM sbtest10 WHERE id BETWEEN ? AND ? [arguments: (545651, 545750)]; |
| SELECT SUM(k) FROM sbtest6 WHERE id BETWEEN ? AND ? [arguments: (457437, 457536)]; |
| SELECT c FROM sbtest6 WHERE id BETWEEN ? AND ? ORDER BY c [arguments: (498261, 498360)]; |
| SELECT DISTINCT c FROM sbtest3 WHERE id BETWEEN ? AND ? ORDER BY c [arguments: (504674, 504773)]; |
| COMMIT;
只跑一种类型的事务SQL,为什么 Local 、Remote 、Distribute 都有?
obclient [oceanbase]> select plan_type, count(1) from gv$ob_sql_audit where request_time > time_to_usec('2021-08-24 18:00:00') group by plan_type order by plan_type;
+-----------+----------+
| plan_type | count(1) |
+-----------+----------+
| 0 | 260 |
| 1 | 1828 |
| 2 | 430 |
| 3 | 11 |
+-----------+----------+