oracle RAC 环境解决sequence 不一致问题

[转]DFS lock handle 问题和现象   接到生产支持的同事报告:数据库反应非常慢,很多数据库操作无法完成,DB出在被hung住的状态。同时,他们通过OEM发现其中一个节点(我们的数据库是10G RAC环境,3个节点)上发现存在很高的“Active Sessions Waiting: Other”的waits,见下图:   分析   ”Active Sessions Waiting: Other”这一类的... 阅读详情

oracle RAC 环境解决sequence 不一致问题

===========================================================

Sequences in Oracle 10g RAC
Just recently I got a call from a developer. He had a table with a primary keypopulated by a sequence, a timestamp column with the current date and someother columns. He had a specific set of data that, when ordered by the primarykey had out of order timestamps. He was puzzled how this could be. This is aRAC database and the sequence was created with the default values.

Not only the sequences cache was thedefault of 20, but it was “noordered”. Being “noordered” Oracle will notguarantee the order in which numbers are generated.

Example of “noorder” sequence in 10gRAC:

Session 1 on node-A: nextval -> 101
Session 2 on node-A: nextval -> 102
Session 1 on node-B: nextval -> 121
Session 1 on node-B: nextval -> 122
Session 1 on node-A: nextval -> 103
Session 1 on node-A: nextval -> 104

The sequence cache is in the sharedpool, therefore sessions on the same node can share the cached entry, butsessions on different nodes cannot. I wonder why Oracle doesnt make “ordered”the default for sequences.

So I explained to the developer howsequences work in RAC and how each node has its own “cache”.

We changed the sequence to “ordered” andincreased the cache to 1000. Now selecting on either node gets the next numberas he expected. I warned him that there would be some performance implicationsdue to cluster synchronization. Him been a responsive developer, asked me whatwould be the impact, so I tested it out.

How does RAC synchronize sequences?


In Oracle 10g RAC, if you specify the “ordered” clause for a sequence, then aglobal lock is allocated by the node when you access the sequence.

This lock acquisition happens only atthe first sequence access for the node (A), and subsequent uses of the sequencedo not wait on this lock. If another node (B) selects from that sequence, itrequests the same global lock and once acquired it returns the sequences nextvalue.

The wait event associated with thisactivity is recorded as “events in waitclass Other” when looked ingv$system_event. So much for event groups, it couldnt be more obscure. Thatview shows overall statistics for the session.

However if you look in thegv$session_wait_history it shows as “DFS lock handle” with the “p1″ parameterbeen the object_id of the sequence. This second view has a sample of the last10 wait events for a session.

In a SQL_TRACE with waitevents (10046trace) it will be a “DFS lock handle” but in AWR or statspack reports it willbe “events in waitclass Other”. So much for consistency.

How does that change our example?

Session 1 on node-A: nextval -> 101(DFS Lock handle) (CR read)
Session 2 on node-A: nextval -> 102
Session 1 on node-B: nextval -> 103 (DFS Lock handle)
Session 1 on node-B: nextval -> 104
Session 1 on node-A: nextval -> 105 (DFS Lock handle)
Session 1 on node-A: nextval -> 106
(more selects)
Session 1 on node-A: nextval -> 998
Session 1 on node-B: nextval -> 999 (DFS Lock handle)
Session 1 on node-B: nextval -> 1000 (CR read)

The cache size also has some RACsynchronization implications. When the cached entries for the sequence areexhausted, the sequence object needs to be updated. This usually causes aremote CR (current read) over the interconnect for the block that has thespecific sequence object. So a bit more activity here.

Test case:

create sequence test_rac;
declare
dummy number;
begin
for i in 1..50000 loop
select test_rac.nextval into dummy from dual;
end loop;
end;
/

Results:

50 000 loops with cache = 20 (default)
1 node = 5 seconds
2 nodes at same time = 14 seconds
2 nodes at same time ordered = 30 seconds

50 000 loops with cache = 1000

1 node = 1.5 seconds
2 nodes at same time = 1.8 seconds
2 nodes at same time ordered = 20 seconds

With a smaller cache, the “noordered”still has as significant impact as every 10 fetches (cache 20 divided by 2nodes fetching) it has to synchronize between the 2 nodes

The conclusion

By default sequences in 10g RAC arecreated without ordering. Beware of using applications that rely on sequencesto be ordered and using it in a RAC environment.

Consider changing all user sequences to“ordered” as a precaution and increasing the cache size.

The default cache value is still verylow and even not-ordered sequences will cause contention in a highly-activesequence even in non-RAC and causing an additional block exchange every 20values in RAC.

For high volume insert operations whereordering is not performed on the value returned from the sequence, considerleaving the sequence “noordered” but increasing the cache size significantly.

Either way, the sequence parametersshould be reviewed, as chances are, the defaults are not what you need.

I remember reading somewhere that inOracle 9i the “ordered” clause in RAC was equivalent to “nochache”. I cantimagine how bad that would be in concurrent selects from the same sequence.

It would be interesting if someonerunning 9i RAC performs the test case and I would appreciate if you post theresults in the comments.

 

Oracle等待事件:DFS锁句柄MySQL DFS锁句柄等待事件是Oracle数据库中常见的等待事件之一。当会话竞争DFS锁句柄资源时,会导致等待事件的发生,从而降低系统的性能和响应时间。通过优化查询语句、调整事务隔离级别、增加资源数量和分析等待事件,可以有效地解决DFS锁句柄等待事件,提升系统的性能和稳定性。以上是关于Oracle等待事件DFS锁句柄MySQL的详细解释和解决方案的文章。希望对您有所帮助!如果您有任何其他问题,请随时提问。 阅读详情

相关推荐

Microsoft Visual C++ 14.0 is required 的亲测最全解决方案(包括安装包丢失或损坏解决方法)

在用python调用别的语言(我用的是cache数据库)的方法时,在执行"python setup3.py install"方法时出现“error: Microsoft Visual C++ 14.0 is required. Get it with “Microsoft Visual C++ Build Tools”错误,以下是网上能找到的安装过程中“所有”解决方案: 1、首先需要下载Micr...

CDL2017CDL的博客 2万+

Oracle等待事件DFS lock handle

在做性能压力测试,测试结果不能通过,获取现场一个小时的AWR报告,发现大量的等待事件,数据库是RAC,版本是11.2.0.4.0。 Snap Id Snap Time Sessions Cursors/Session Instances Begin Snap: 1607 21-10月-14 20:00:03 560

关注系统性能调优 1万+

红队之社工钓鱼exe伪装jpg图片

ss5d 编辑重用名 插入Unicode 然后选择RLO。我们要用到RLO伪装 gpj.exe pdf。然后我们进行转换按钮会生成一个exe文件。把1.jpg还有exe添加进来即可。版本信息可填写可不填。

大雾 1376

DFS lock handle事件处理

环境: Oracle 11.2.0.1 RAC AXI 6.3 情况:工具通过INSRT INTO TAB1@DB_LINK SELECT * FROM TAB_B往插入数据时,HAND住,会话事件为DFS lock h...

cnqc11810的博客 2484

避坑指南:用pygrib处理ERA5气象数据时遇到的5个典型问题

本文总结了使用pygrib库处理ERA5气象GRIB数据时常见的五个典型问题及解决方案,涵盖数据获取、内存管理、时间处理、空间插值和性能优化。重点针对气象数据插值这一核心挑战,提供了处理不规则网格、缺失值和跨日期变更线的实用代码示例与优化策略,帮助用户高效、稳定地完成气象数据分析工作。

weixin_28224217的博客 187

华为IPD实战:从概念到发布的完整流程拆解(附各阶段关键文档模板)

本文深入拆解华为IPD(集成产品开发)从概念到发布的完整实战流程,涵盖概念、计划、开发验证及发布生命周期四大阶段。详细解析了各阶段的核心活动、关键产出与决策评审点,并提供了如《初始业务计划书》等关键文档模板框架,旨在帮助企业将IPD理论转化为可执行的操作指南,提升研发效率与产品成功率。

weixin_29212429的博客 547

oracle seq等待事件,AWR分析之DFS lock handle等待事件 | 信春哥,系统稳,闭眼上线不回滚!...

在给客户巡检时发现DFS lock handle等待事件。在RAC环境中,会话等待获取一个全局锁的句柄时产生DFS lock handle等待事件,这个等待事件通常和sequence有关,如果2个实例都有并发的session使用sequence,这时有可能遭遇 DFS LOCK HANDLE等待事件。ORACLE为了在RAC环境下为了sequence的一致性,使用了三种锁:row cache lo...

weixin_32048835的博客 812

7系列ZYNQ硬件调试:Vitis无法识别ARM DAP的排查与解决

本文针对7系列ZYNQ开发中Vitis无法识别ARM DAP的典型硬件调试问题,提供了系统性的排查与解决方案。文章深入剖析了问题本质,指出ARM DAP无法访问的核心原因在于PS部分的电源、时钟或复位等硬件基础条件未满足,并重点强调了PS参考时钟(如33.333MHz晶振)的完整性是关键排查点。通过从电源完整性、时钟与复位信号到JTAG连接与焊接的逐步硬件排查,并结合软件配置交叉验证,为开发者提供了清晰的故障定位思路与实战指南。

weixin_29280657的博客 638

oracle解决rac序列,oracle RAC 环境解决sequence 不一致问题

oracle RAC环境解决sequence不一致问题===========================================================Sequences in Oracle 10g RACJust recently I got a call from a developer. He had a table with a primary keypopulated...

weixin_26907223的博客 996

CH341的I2C流模式(StreamI2C)到底怎么用?从EEPROM读写到自定义设备,一篇讲清参数配置逻辑

本文详细解析了CH341的I2C流模式(StreamI2C)的使用方法,从EEPROM读写到自定义设备的参数配置逻辑。通过深入分析I2C协议基础、StreamI2C参数映射关系及典型设备配置示例,帮助开发者快速掌握StreamI2C的应用技巧,解决实际开发中的常见问题。

weixin_30932215的博客 458

Power BI常见问题篇1:无法打开文档

Power BI常见问题篇1:无法打开文档

weixin_48273257的博客 3313

oracle集群sequence重复,oracle RAC 环境解决sequence 不一致问题

Sequences in Oracle 10g RACJust recently I got a call from a developer. He had a table with a primary key populated by a sequence, a timestamp column with the current date and some other columns. He h...

weixin_39860583的博客 1416

TC397 EB MCAL开发从0开始系列 之 [13.1] Dma配置实战 -实现M2M数据传输(读存储写存储)

TC3XX TC397 MCAL DMA 从0搭建测试用例-实现M2M 存储到存储数据传输

yy九歌的博客 1930

Oracle序列sequence cache nocache、RAC

一、问题描述:新增了个表,上了生产环境之后,发现ID跳号且穿插,如图1所示。 而测试环境只是跳号,如图2所示。 图1 生产环境 图2 ...

开着奥迪卖小猪 4543

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

oracle rac环境中的sequence

oracle为了在rac环境下为了sequence的一致性,使用了三种锁:row cache lock、SQ锁、SV锁。的目的是在sequence指定nocache的情况下调用sequence.nextval过程中保证序列的顺序性;是应用于指定了cache+noorder的情况下调用sequence.nextval过程中。(dfs lock handel) 是调用sequence.nextval期间拥有的锁。前提是创建sequence时指定了cache 和order属性 (cache+order)。

狗剩儿的记忆博客 872

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

RAC环境下的SEQUENCE对应用的影响

生产系统上了RAC,几天后接到同事报告,说一个取sequence的地方数据有问题,按数据插入时间来判断先取的sequence值大,而后取的反而小,与之前对sequence的理解有出入。测试如下[@more@]在节点一上:Conn...

crazycat123456的博客 284

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

oracle rac一个节点执行语句很慢_由点及面了解Oracle的Sequence序列

点击标题下「蓝色微信名」可快速关注预计阅读时间:22分钟sequence作为Oracle一个非常普通的对象,在实际设计和开发的过程中,还是有些知识,以及细节,值得总结和注意,下面我会从四个方面,展开介绍,1. sequence基本介绍2. sequence性能问题3. 18c的sequence新特性4. 一些开发中sequence的使用经验1. sequence基本介绍下图是11g的《R...

weixin_39560064的博客 744

ORACLE SEQUENCE

sequence的概念及作用sequence是用来在多用户环境下产生唯一整数的数据库对象。序列产生器顺序生成数字,它可用于自动生成主键值,并能协调多行或者多表的主键操作。没有sequence,顺序的值只能靠编写程序来生成。先找出最近产生的值然后自增长。这种方法要求一个事务级别的锁,这将导致在多用户并发操作的环境下,必须有人等待下一个主键值的产生。而且此方法很容易产生主键冲突的错误,如下图:ti

oracle 数据库优化-松森科技 3855

oracle sequences优化_性能优化-Oracle RAC中的Sequence Cache问题

性能优化-Oracle RAC中的Sequence Cache问题enq: SQ - contention在RAC情况下,可以将使用频繁的序列Cache值增加到10000,或者更高到50000,这些值在客户的环境中都有采用。这是RAC设置和RAC使用的基本常识,不可或忘。在以下测试中,可以显示Cache序列对于性能的影响:http://space.itpub.net/14941137/viewsp...

weixin_39710295的博客 565

oracle的nextval乱序,ORACLE RAC环境下读取序列乱序问题

在数据库部署了RAC环境之后,偶尔会出现从Oracle Sequence所取出来的数是混乱的,比如第二次比第一次所取的数要小。这样当程序的逻辑依赖于ID的大小来排序时,就会产生系统混乱。其实问题是出在数据库是个RAC环境,序列是被共享的,序列默认是有缓存的。假设RAC上的两个节点上序列缓存设为20,第一个节点上缓存1-20,第二个节点缓存了21-40,当从不同节点来进行对sequence取值的时候...

weixin_31293733的博客 1312

ORACLE RAC环境下读取序列乱序问题

在数据库部署了RAC环境之后,偶尔会出现从Oracle Sequence所取出来的数是混乱的,比如第二次比第一次所取的数要小。这样当程序的逻辑依赖于ID的大小来排序时,就会产生系统混乱。 其实问题是出在数据库是个RAC环境,序列是被共享的,序列默认是有缓存的。假设RAC上的两个节点上序列缓存设为20,第一个节点上缓存1-20,第二个节点缓存了21-40,当从不同节点来进行对sequenc

重剑无锋,大巧不工。。。 1万+

oracle 序列_详解Oracle数据库中序列的使用及RAC中的Sequence Cache问题

概述所谓序列,在oracle中就是一个对象,这个对象用来提供一个有序的数据列,这个有序的数据列的值都不重复。序列(Sequence)是用来生成连续的整数数据的对象,常常用来作为主键中增长列,序列中的可以升序生成,也可以降序生成。语法结构:创建序列CREATE SEQUENCE sequence_name[START WITH num][INCREMENT BY increment][MAXVALU...

weixin_39613188的博客 665

oracle数据库sequence的作用

sequence的命名最重要的是要统一,命名规则是次要的。cache参数告诉oracle预先分配一个sequence numbers的集合,并且保留在内存中,以便sequence number能够被快速的访问。这个内存的大小就是cache所指定的大小,当多个用户同时访问一个sequence的时候,是在oracle SGA中读取sequence当前的合理数值,如果并发访问太大,cache的大小不够,那么就会产生sequence cache相关的等待(enq: SQ – contention),影响系统性能。

2301_77783312的博客 980

Oracle开发误区探索【三】(Sequence)

通过上述实验,我们可以明白,其实sequece要保证连续中间不断号是很困难的,如果我们是采用cache的形式,重启数据库或者内存被清空等情况都会导致缓存在cache中的连续号被清空,就产生断号了,其实即便我们不设置cache,比如设置了nocache的关键字,一样会丢失...

从底层逻辑去思考技术,去拥抱变化 1129

Oracle Sequence 你真的了解吗

序列(SEQUENCE)是序列号生成器,可以自动产生一组等间隔的数值(类型为数字)。是Oracle实现自动增长的一种方式, 不占用磁盘空间,占用内存。其主要用途是生成表的主键值,可以在插入语句中引用,也可以通过查询检查当前值,或使序列增至下一个值。 1. 创建序列的语法   CREATE SEQUENCE序列名   [INCREMENT BY n]   [START WITH n]   [{MAXVALUE/ MINVALUE n| NOMAXVALUE}]   [{CYCLE|...

Keep learing, and stay fast 2168
上一篇: lsof
下一篇: linux 快捷键
zljjava
博客等级 码龄15年 155粉丝 15原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值