File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,22 @@ func (db *oracleDatabase) prerequisiteArchiveLogRetention(ctx context.Context) e
30
30
if err := db .switchToCDB (ctx ); err != nil {
31
31
return err
32
32
}
33
- var row = db .conn .QueryRowContext (ctx , "SELECT MIN(FIRST_TIME) FROM V$ARCHIVED_LOG A WHERE A.NAME IS NOT NULL" )
33
+ var row = db .conn .QueryRowContext (ctx , "select created from v$database" )
34
+ var databaseAge time.Time
35
+ if err := row .Scan (& databaseAge ); err != nil {
36
+ return fmt .Errorf ("querying database age from DBA_OBJECTS: %w" , err )
37
+ }
38
+
39
+ log .WithFields (log.Fields {
40
+ "created" : databaseAge ,
41
+ }).Debug ("database age" )
42
+
43
+ if time .Since (databaseAge ) < (time .Hour * 24 ) {
44
+ log .Warn ("database age is less than 24 hours, skipping retention checks" )
45
+ return nil
46
+ }
47
+
48
+ row = db .conn .QueryRowContext (ctx , "SELECT MIN(FIRST_TIME) FROM V$ARCHIVED_LOG A WHERE A.NAME IS NOT NULL" )
34
49
var minTimestamp time.Time
35
50
if err := row .Scan (& minTimestamp ); err != nil {
36
51
return fmt .Errorf ("querying minimum archived log timestamp from V$ARCHIVED_LOG: %w" , err )
You can’t perform that action at this time.
0 commit comments