Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-oracle: skip retention checks for new databases #2533

Merged
merged 1 commit into from
Mar 18, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion source-oracle/prerequisites.go
Original file line number Diff line number Diff line change
@@ -30,7 +30,22 @@ func (db *oracleDatabase) prerequisiteArchiveLogRetention(ctx context.Context) e
if err := db.switchToCDB(ctx); err != nil {
return err
}
var row = db.conn.QueryRowContext(ctx, "SELECT MIN(FIRST_TIME) FROM V$ARCHIVED_LOG A WHERE A.NAME IS NOT NULL")
var row = db.conn.QueryRowContext(ctx, "select created from v$database")
var databaseAge time.Time
if err := row.Scan(&databaseAge); err != nil {
return fmt.Errorf("querying database age from DBA_OBJECTS: %w", err)
}

log.WithFields(log.Fields{
"created": databaseAge,
}).Debug("database age")

if time.Since(databaseAge) < (time.Hour * 24) {
log.Warn("database age is less than 24 hours, skipping retention checks")
return nil
}

row = db.conn.QueryRowContext(ctx, "SELECT MIN(FIRST_TIME) FROM V$ARCHIVED_LOG A WHERE A.NAME IS NOT NULL")
var minTimestamp time.Time
if err := row.Scan(&minTimestamp); err != nil {
return fmt.Errorf("querying minimum archived log timestamp from V$ARCHIVED_LOG: %w", err)
Loading