oracle sql 不能输入 光标自动跳到本行末尾 insert,ORA-01591故障处理-数据库专栏,ORACLE...

早晨到办公室听同事说表被锁了,一试,发现表中某字段为1111111的行都被锁了,select都不行。报错误ora-01591,打开toad的knowledge expert,描述很少,只是说由于分布式事务错误而造成锁定。询问同事,昨天通过一个存储过程调用另一个存储过程出了错误,而后者通过透明网关insert一些数据到sql server数据库。

立即想到打开oem,谁知道大失所望,进入锁,根本没发现相关的对象被锁定,开始有点郁闷。转而检查会话,该用户有5个会话,都是inactive,不管三七二十一,全部杀掉。结果依旧,并且锁也没有出现。远程登陆上主机,发现cpu和进程都正常,也没有发现透明网关进程挂死(之前曾发现tg4sql在无业务量时也会出现25%左右的cpu,挂死)。

突然想到看看alert.log,经过仔细搜索,终于发现:

wed nov 17 00:00:04 2004

errors in file d:\oracle\admin\xdcj\udump\xdcj_j006_3020.trc:

ora-12012: 自动执行作业 82 出错

ora-01591: 锁定已被有问题的分配事务处理6.5.887985挂起

ora-06512: 在line 6

这正是出错的地方,往前追溯:

tue nov 16 17:35:04 2004

error 28500 trapped in 2pc on transaction 6.5.887985. cleaning up.

error stack returned to user:

ora-02054: 事务处理6.5.887985有问题

ora-28500: 连接 oracle 到非 oracle 系统时返回此信息:

[transparent gateway for mssql]

ora-02063: 紧接着2 lines(源于zsmos_crm)

tue nov 16 17:35:04 2004

distrib tran qdcj.us.oracle.com.5ae32328.6.5.887985

is local tran 6.5.887985 (hex=06.05.d8cb1)

insert pending prepared tran, scn=6606197672830 (hex=602.2010cb7e)

tue nov 16 17:35:07 2004

errors in file d:\oracle\admin\xdcj\bdump\xdcj_reco_3024.trc:

ora-28500: connection from oracle to a non-oracle system returned this message:

[transparent gateway for mssql][microsoft][odbc sql server driver][sql server]用户 recover 登录失败。 (sql state: 28000; sql code: 18456)

ora-02063: preceding 2 lines from zsmos_crm

tue nov 16 17:35:12 2004

errors in file d:\oracle\admin\xdcj\bdump\xdcj_reco_3024.trc:

ora-28500: connection from oracle to a non-oracle system returned this message:

[transparent gateway for mssql][microsoft][odbc sql server driver][sql server]用户 recover 登录失败。 (sql state: 28000; sql code: 18456)

ora-02063: preceding 2 lines from zsmos_crm

这就是事发地点了。看来是昨天下午远程事务失败,但是又没有返回造成分布式事务挂死,从而锁定了行。终于找到了详细的错误ora-02054,进入toad一查,说是要等待或者提交该事务,可是怎么操作呢。还是打开官方文档搜索相关内容,在adminstrator guide中发现如下内容:

discovering problems with a two-phase commit

the user application that commits a distributed transaction is informed of a problem by one of the following error messages:

ora-02050: transaction id rolled back,

some remote dbs may be in-doubt

ora-02051: transaction id committed,

some remote dbs may be in-doubt

ora-02054: transaction id in-doubt

a robust application should save information about a transaction if it receives any of the above errors. this information can be used later if manual distributed transaction recovery is desired.

no action is required by the administrator of any node that has one or more in-doubt distributed transactions due to a network or system failure. the automatic recovery features of oracle transparently complete any in-doubt transaction so that the same outcome occurs on all nodes of a session tree (that is, all commit or all roll back) after the network or system failure is resolved.

in extended outages, however, you can force the commit or rollback of a transaction to release any locked data. applications must account for such possibilities.

determining whether to perform a manual override

override a specific in-doubt transaction manually only when one of the following situations exists:

the in-doubt transaction locks data that is required by other transactions. this situation occurs when the ora-01591 error message interferes with user transactions.

an in-doubt transaction prevents the extents of a rollback segment from being used by other transactions. the first portion of an in-doubt distributed transactions local transaction id corresponds to the id of the rollback segment, as listed by the data dictionary views dba_2pc_pending and dba_rollback_segs.

the failure preventing the two-phase commit phases to complete cannot be corrected in an acceptable time period. examples of such cases include a telecommunication network that has been damaged or a damaged database that requires a long recovery time.

normally, you should make a decision to locally force an in-doubt distributed transaction in consultation with administrators at other locations. a wrong decision can lead to database inconsistencies that can be difficult to trace and that you must manually correct.

if the conditions above do not apply, always allow the automatic recovery features of oracle to complete the transaction. if any of the above criteria are met, however, consider a local override of the in-doubt transaction.

看来是建议差不多,后面oracle总是试图登录sql server就是要自动恢复,可是总不成功。察看视图dba_2pc_pending确实发现了该事务的痕迹。要怎样操作呢?

manually committing an in-doubt transaction

before attempting to commit the transaction, ensure that you have the proper privileges. note the following requirements:

if the transaction was committed by… then you must have this privilege…

you

force transaction

another user

force any transaction

committing using only the transaction id

the following sql statement commits an in-doubt transaction:

commit force transaction_id;

the variable transaction_id is the identifier of the transaction as specified in either the local_tran_id or global_tran_id columns of the dba_2pc_pending data dictionary view.

for example, assume that you query dba_2pc_pending and determine that local_tran_id for a distributed transaction is 1:45.13.

you then issue the following sql statement to force the commit of this in-doubt transaction:

commit force 1.45.13;

committing using an scn

optionally, you can specify the scn for the transaction when forcing a transaction to commit. this feature allows you to commit an in-doubt transaction with the scn assigned when it was committed at other nodes.

consequently, you maintain the synchronized commit time of the distributed transaction even if there is a failure. specify an scn only when you can determine the scn of the same transaction already committed at another node.

for example, assume you want to manually commit a transaction with the following global transaction id:

sales.acme.com.55d1c563.1.93.29

first, query the dba_2pc_pending view of a remote database also involved with the transaction in question. note the scn used for the commit of the transaction at that node. specify the scn when committing the transaction at the local node. for example, if the scn is 829381993, issue:

commit force sales.acme.com.55d1c563.1.93.29, 829381993;

see also:

oracle9i sql reference for more information about using the commit statement

manually rolling back an in-doubt transaction

before attempting to roll back the in-doubt distributed transaction, ensure that you have the proper privileges. note the following requirements:

if the transaction was committed by… then you must have this privilege…

you

force transaction

another user

force any transaction

the following sql statement rolls back an in-doubt transaction:

rollback force transaction_id;

the variable transaction_id is the identifier of the transaction as specified in either the local_tran_id or global_tran_id columns of the dba_2pc_pending data dictionary view.

for example, to roll back the in-doubt transaction with the local transaction id of 2.9.4, use the following statement:

rollback force 2.9.4;

于是登陆数据库

commit force 6.5.887985;

然后查看dba_2pc_pending发现状态已经改为commit force,select该表相关行,一切正常。至此,故障解决。

总体来看,直接insert … tablename@sqldblk还是很危险的,遇上不能正常返回就出问题了。oracle的文档是推荐使用包或者存储过程来解决,此后建议同事改用此方法,目前已经测试通过。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值