为应对多点部署保证高并发场景使用正确添加排它锁

This commit is contained in:
cjl
2019-02-01 16:07:06 +08:00
parent 66baa3dfa0
commit b1d74a161c
2 changed files with 1 additions and 1 deletions

View File

@@ -5277,7 +5277,7 @@ declare _maxvalue bigint; -- 接收最大值
declare _increment int; -- 接收增长步数
set _increment = (select increment_val from tbl_sequence where seq_name = name);
set _maxvalue = (select maxvalue from tbl_sequence where seq_name = name);
set _cur = (select current_val from tbl_sequence where seq_name = name);
set _cur = (select current_val from tbl_sequence where seq_name = name for update);
update tbl_sequence -- 更新当前值
set current_val = _cur + increment_val
where seq_name = name ;