We had this issue while trying to enable flashback:
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-04031: unable to allocate 31874944 bytes of shared memory ("shared
pool","unknown object","sga heap(2,0)","flashback generation buffer")
SQL>
In our case this was due to “ORA-4031 When Enabling Flashback In 19c (Doc ID 2896925.1)”:
Cause:
This is due to insufficient contiguous space in shared pool required for as flashback buffer.
Solution:
To avoid future similar errors, set the following parameter and restart the database:
alter system set "_allocate_flashback_buffer"=TRUE scope=spfile sid='*';
This will pre-allocate flashback buffer during database startup. Memory will be allocated even if we don't plan to create restore point later.
Since this was just for a one-off activity Client wanted to implement, we did not put the solution as we wanted to better have teh memory available for the DB instead of bein preallocated, so instead we just restarted DB and enabled right away without issues:
hostname1# srvctl status db -d DB
Instance DB1 is running on node hostname1
Instance DB2 is running on node hostname2
hostname1# srvctl stop db -d DB
hostname1# srvctl status db -d DB
Instance DB1 is not running on node hostname1
Instance DB2 is not running on node hostname2
hostname1# srvctl start db -d DB
SQL> alter database flashback on;
Database altered.
SQL> CREATE RESTORE POINT BEFORE_CHANGE GUARANTEE FLASHBACK DATABASE;
Restore point created.
Comments
If you add additional 1GB to SGA and bounce the db , this issue can be fixed ! We implemented successfully!