Erro: ORA-22924: snapshot too old
Autor: Sarah Luz | Publicado: 2013-04-17T12:10:00-07:00



O post de hoje é sobre o erro: ORA-22924: snapshot too old



Em um belo dia estava realizando um expdp de uma base de aproximadamente 60GB, no log de exportação foi apresentado o erro abaixo:



ORA-31693:
Table data object "owner"."tabela" failed to load/unload
and is being skipped due to error:



ORA-29913:
error in executing ODCIEXTTABLEPOPULATE callout



ORA-01555:
snapshot too old: rollback segment number&nbsp;
with name "" too small



ORA-22924:
snapshot too old



Teoria importante:&nbsp;&nbsp;

Tablespace UNDO:&nbsp;&nbsp;Sempre que uma transação é iniciada, ela é direcionada para um segmento UNDO, quando os dados são alterados os valores antigos são copiados para o segmento, a função da UNDO é sobrescrever as transaçãoes submetidas a commit ainda nao expiradas.



È interessante antes de tudo entender o que está fazendo, a teoria é fundamental.

Para consultar o tamanho da UNDO, execute o script abaixo:

SELECT&nbsp;&nbsp;&nbsp;&nbsp; d.undo_size/(1024*1024) "ACTUAL UNDO SIZE [MByte]",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SUBSTR(e.value,1,25) "UNDO RETENTION [Sec]",
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (TO_NUMBER(e.value) * TO_NUMBER(f.value) *
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; g.undo_block_per_sec) / (1024*1024)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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undo_block_per_sec
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; FROM&nbsp;&nbsp;&nbsp; v$undostat) g
&nbsp;&nbsp; WHERE&nbsp;&nbsp; e.name = 'undo_retention'
&nbsp;&nbsp; AND&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; f.name = 'db_block_size';




Com intuito de resolver o problema, tentei aumentar gradativamente o tamanho da tablespace UNDO, mesmo&nbsp; aumentando o tamanho, o problema persistiu.



Depois de quebrar muita a cabeça...&nbsp;&nbsp; Fiz outra tentativa:



Alterar o periodo de retenção da UNDO.




Aumentei gradativamente o tamanho para 2 dias.

O calculo é&nbsp; por segundos:

&nbsp;&nbsp; 1 hora = 60 segundos 
&nbsp;&nbsp; 48horas = 2 dias
&nbsp;&nbsp; 60 * 48 = 4320
&nbsp;&nbsp; Valor a ser alterado= 4320s


Primeiro, deve ter permissão de sys para alterar o tempo de retenção:



export ORACLE_SID=instãncia&nbsp;&nbsp; - Primeiro necessita informar ao SGDB qual instância deseja que seja aumentada a UNDO.



sqlplus / as sysdba





Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@instância SQL&gt;


ALTER SYSTEM SET UNDO_RETENTION = 604800 scope=both 



System altered.



Não é necessário realizar shutdown no banco de dados.



Após alteração, o erro mesmo assim persistiu no log do expdp:



ORA-31693: Table data object "owner"."tabela" failed to load/unload and is being skipped due to error:



ORA-29913: error in executing ODCIEXTTABLEPOPULATE callout

ORA-01555: snapshot too old: rollback segment number with name "" too small



ORA-22924: snapshot too old



Outra tentativa aumentei&nbsp; UNDO_RETENTION&nbsp; para uma semana:



export ORACLE_SID=instância  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Primeiro necessita informar ao SGDB qual instância deseja que 


seja aumentada a UNDO.



sqlplus / as sysdba&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- Logar com SYS





Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SYS@instância SQL&gt;


ALTER SYSTEM SET UNDO_RETENTION = 604800 scope=both;


System altered.


Após alteração&nbsp;o expdp foi realizado com sucesso:









Job "SYSTEM"."SYS_EXPORT_SCHEMA_01" successfully completed at 06:38:11





Abraço galera!



FIM DO POST!