天天看点

DROP_SNAPSHOT_RANGE过程不能清理表RM$_SNAPSHOT_DETAILS

    今天在测试、验证DROP_SNAPSHOT_RANGE不能彻底快照的过程中遇到了DROP_SNAPSHOT_RANGE无法清理WRM$_SNAPSHOT_DETAILS表中数据的情况,测试服务器版本为10.2.0.4.0,AWR的快照是1小时采集一次数据,快照保留14天,也就是二周。具体情况如下所示:

DROP_SNAPSHOT_RANGE过程不能清理表RM$_SNAPSHOT_DETAILS

PL/SQL procedure successfully completed.

<a href="http://images2015.cnblogs.com/blog/73542/201607/73542-20160722103801794-1713507451.png"></a>

    如上实验所示,DROP_SNAPSHOT_RANGE不能清理WRM$_SNAPSHOT_DETAILS中的数据,当然对于的空间就不会释放,另外,有些版本中Oracle仅仅修改了对应SNAPSHOT的状态,而并没有删除快照。PS:有些人可能被上面又是DBA_HIST_SNAPSHOT,又是WRM$_SNAPSHOT_DETAILS弄得有点晕,其实DBA_HIST_SNAPSHOT是视图,它的数据来源于表WRM$_SNAPSHOT_DETAILS,使用下面SQL就能查看具体定义

SELECT OWNER, VIEW_NAME, TEXT FROM DBA_VIEWS WHERE VIEW_NAME='DBA_HIST_SNAPSHOT';

-------------------------------------------------------------分割线------------------------------------------------------

本来这篇文章写了好几天了,后面讨论发现其实有时候AWR快照不能删除,并不一定就是bug,也有可能是设置了AWR的基线,下面我来演示一下

<a href="http://images2015.cnblogs.com/blog/73542/201607/73542-20160722103802732-649354079.png"></a>

AWR快照SNAP_ID从7455 到7458 删除不掉,其实是因为这个段的快照设置成了基线,如下截图所示,所以,如果你发现快照删除不了的话,最好先检查这个SNAP_ID段是否设置成了基线。

<a href="http://images2015.cnblogs.com/blog/73542/201607/73542-20160722103803576-547869485.png"></a>

另外还有就是有可能一个Bug引起的,这个只出现在特定版本中,官方文档WRM$_SNAPSHOT_DETAILS Table is Not Purged (文档 ID 1489801.1) 和文档 Document 9797851.8 Bug 9797851 - WRM$_SNAPHOST_DETAILS is never purged 都有描述这个Bug

Oracle Database - Enterprise Edition - Version 11.2.0.3 to 12.1.0.1 [Release 11.2 to 12.1]

Information in this document applies to any platform.

The following symptoms are observed:

AWR purge code is not automatically purging WRM$_SNAPSHOT_DETAILS, as expected

Even after dropping a range of snap id's using dbms_workload_repository.drop_snapshot_range(), the table is not purged.

Table WRM$_SNAPSHOT_DETAILS grows indefinitely.

There are many orphaned entries in the table WRM$_SNAPSHOT_DETAILS.

The number of orphaned rows for the table WRM$_SNAPSHOT_DETAILS can be found by running the following sql:

This issue is caused by an unpublished bug:

The verification criteria for the bug are:

Drop a range of snap id's using dbms_workload_repository.drop_snapshot_range()

Check the corresponding snap id's in WRM$_SNAPSHOT_DETAILS.

If snap id's from the range that you chose to drop are still present, then you are hitting this bug.

The following solutions are available:

If the patch is not available on your platform on a supported version, please contact Oracle Support.

This issue will be fixed from release Oracle 12.1

As a workaround, it is possible to manually purge the range of snap id's from the table WRM$_SNAPSHOT_DETAILS using appropriate delete statments under the guidance of Oracle Support.

Note:

在下面版本中,这些bug才fix掉了,请留意自己的版本信息。

DROP_SNAPSHOT_RANGE过程不能清理表RM$_SNAPSHOT_DETAILS