有套生产系统由于数据量比较大,当时图方便直接建成了bigfile tablespace,用起来也没啥不同,只是在RMAN备份的时候发现无法多进程来备份该表空间,导致备份时间稍长,虽觉不爽,但咬咬牙也就忍了。
但是,有天早上上班,发现表空间使用率有点高,于是resize扩了下,结果发现,库上有一堆的会话被阻塞。心慌慌。幸亏resize值不大,几秒钟过去。在我理解中,数据库在线resize数据文件理论上不应该存在阻塞的情况。后来想了想,估计是bigfile的原因。
在MOS上搜索了下"bigfile resize cause block session",果然找到了些文章,如:
Alter Tablespace Resize on Bigfile Tablespace Causes Sessions to Hang with 'Enq: TX - contention' and 'Buffer busy waits' (Doc ID 2089689.1)
有如下阐述:
This is expected behaviour.
If a tablespace has only one datafile, extent allocation will always wait while a tablespace is being resized. This is because extent allocations as well as datafile extend operations serialize on the header block of the datafile. If the tablespace has more than one datafile, then Oracle may be able to allocate the extent in another datafile without having to wait. Since a bigfile tablespace has only one datafile, extent allocations will wait if the tablespace is being resized.
This is an unfortunate issue with bigfile tablespaces.
对于该问题,文章中不无无奈的推荐了两种方式:
1、业务空闲时候resize
2、可以resize,但是呢,分批做,每次resize一点点,这样的话,阻塞的时间可以控制在很短时间内。
---------------------------------------------------
目前数仓那边很多表空间用的都是bigfile ,但由于是管理类系统,倒是没有多大影响。但涉及实时交易的,今后还需注意,还是使用普通表空间了。