首批通过分布式安全可靠测评,为关键业务系统打造
OceanBase 数据库事务触发同步 CLOG 时机梳理
更新时间:2026-06-12 04:01
OceanBase 数据库 V2.x 和 V3.x 版本事务在写 CLOG 时机上存在不同。
- OceanBase 数据库 V2.x 版本:事务 commit 时才写日志。
- OceanBase 数据库 V3.x 版本:触发 clog 同步(落盘)的时机如下:
- 事务 commit。
- 转储未提交事物时。
- 当某一事务内存中剩余需要同步的数据量超过内部配置项
_private_buffer_size时。
当某一事务内存中剩余需要同步的数据量超过配置项 _private_buffer_size 时,触发即时写日志。如果 _private_buffer_size =0,则不会触发即时写日志,只能在 commit 时或转储时来写日志。
即时写日志是指事务在内存中剩余需要同步的数据量超过某一定值时,会将内存中需要同步的数据量立即同步到备机。能够保证在主动切主时, 需要搬迁的数据量小于定值, 从而保证切主时需要同步的数据量可控, 能达到平滑切主不杀事务的目的。
注意
_private_buffer_size 为隐藏配置项。不同版本的 OceanBase 数据库中 _private_buffer_size 的默认值可能会有所不同。因此, 在使用 OceanBase 数据库时,需要根据具体版本的文档来进行配置。
obclient [oceanbase]> select * from __all_virtual_sys_parameter_stat where name like '%private_buffer%';
+------+----------+-----------+----------+----------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+
| zone | svr_type | svr_ip | svr_port | name | data_type | value | value_strict | info | need_reboot | section | visible_level | scope | source | edit_level |
+------+----------+-----------+----------+----------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+
| z1 | observer | 127.x.x.x | 2882 | _private_buffer_size | NULL | 2M | NULL | [0B,)the trigger remaining data size within transaction for immediate logging, 0B represents not trigger immediate loggingRange: [0B, total size of memory] | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| z2 | observer | 127.x.x.x | 3882 | _private_buffer_size | NULL | 2M | NULL | [0B,)the trigger remaining data size within transaction for immediate logging, 0B represents not trigger immediate loggingRange: [0B, total size of memory] | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
| z3 | observer | 127.x.x.x | 4882 | _private_buffer_size | NULL | 2M | NULL | [0B,)the trigger remaining data size within transaction for immediate logging, 0B represents not trigger immediate loggingRange: [0B, total size of memory] | NULL | OBSERVER | NULL | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE |
+------+----------+-----------+----------+----------------------+-----------+-------+--------------+-------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+----------+---------------+---------+---------+-------------------+
3 rows in set (0.202 sec)
适用版本
OceanBase 数据库 V2.x 和 V3.x 版本。