ORA-03262: the file is non-empty when dropping a datafile

When dropping a datafile online from a tablespace, get below error:

SQL> alter tablespace TEST_TBS drop datafile '+DG1/ractest/datafile/test_tbs.521.1000824921';
alter tablespace TEST_TBS drop datafile '+DG1/ractest/datafile/test_tbs.521.1000824921'
*
ERROR at line 1:
ORA-03262: the file is non-empty

The datafile can be dropped online only if the datafile is empty:

SQL> alter tablespace TEST_TBS add datafile '+DG1' size 1m ;

Tablespace altered.

 SQL> alter tablespace TEST_TBS drop datafile '+DG1/ractest/datafile/test_tbs.483.1000830099';

Tablespace altered.

ORA-00261: log 11 of thread 1 is being archived or modified

Try to drop standby logfile group, and get below errors. Because this standby logfile group is being used for real time standby database recovery.

SQL> alter database drop standby logfile group 11;
alter database drop standby logfile group 11
*
ERROR at line 1:
ORA-00261: log 11 of thread 1 is being archived or modified
ORA-00312: online log 11 thread 1: '/u02/redo/TESTDB/standby_011.log'

WORKAROUND

1)Clear standby logfiles:

SQL> alter database clear logfile group 11;

Database altered.

2) Drop standby logfile group:

SQL> alter database drop standby logfile group 11;

Database altered.

3) Add standby logfile groups, and enable recovering managed standby database.

4) Will see log shipping pauses with below errors :

*** 2019-01-21 15:11:39.944
Error 270 closing standby archive log file at host 'TESTDBSTY'
ORA-00270: error creating archive log
Archive destination LOG_ARCHIVE_DEST_2 made inactive: File close error
*** 2019-01-21 15:11:40.043603 4929 krsh.c
LGWR: Error 270 closing archivelog file 'TESTDBSTY'

5) Reset parameter “log_archive_dest_state_2” to wake up log shipping:

SQL>alter system set log_archive_dest_state_2=enable;

ORA-01031: insufficient privileges by EXECUTE IMMEDIATE

“ORA-01031: insufficient privileges” was received from a PL/SQL procedure  “EXECUTE IMMEDIATE” state.

1)Create a simple PL/SQL procedure.

SQL> create or replace procedure proc_test
is
begin
          EXECUTE IMMEDIATE 'create table tbl_test ( id number)';
end;

2) logon as user ,and then execute above procedure.

SQL> exec proc_test;
BEGIN proc_test; END;

*
ERROR at line 1:
ORA-01031: insufficient privileges
ORA-06512: at "TEST_USER.PROC_TEST", line 7
ORA-06512: at line 1

3) grant ‘create table’ privilege to user directly.

SQL> show user
USER is "SYS"
SQL> grant create table to test_user;

Grant succeeded.

4)logon as user ,and then execute above procedure.

SQL> show user
USER is "TEST_USER"

SQL> exec proc_test;

PL/SQL procedure successfully completed.

SQL> desc tbl_test;
Name   Null?   Type
----- -------- ----------------------------
ID             NUMBER

SQL> drop table tbl_test;

REASON: In stored procedure/function, any privileges granted by a role will NOT be effective. The privileges should be directly granted to the user.

DataGuard ORA-07286 ORA-16055 ORA-19809 ORA-19804 ORA-19815

SYMPTOM

On primary database  side, ORA errors in alert log:

Sat Sep 22 03:56:48 2018
Errors in file /u01/app/oracle/diag/rdbms/ractest/RACTEST1/trace/RACTEST1_arc4_20835.trc:
ORA-07286: sksagdi: cannot obtain device information.
Sat Sep 22 03:56:48 2018
ARC4: FAL archive failed with error 7286. See trace for details
Sat Sep 22 03:56:48 2018
Errors in file /u01/app/oracle/diag/rdbms/ractest/RACTEST1/trace/RACTEST1_arc4_20835.trc:
ORA-16055: FAL request rejected
ARCH: FAL archive failed. Archiver continuing

On standby database side :

ORA-19809: limit exceeded for recovery files
ORA-19804: cannot reclaim 536870912 bytes disk space from 214748364800 limit
ORA-19815: WARNING: db_recovery_file_dest_size of 214748364800 bytes
           is 100.00% used, and has 0 remaining bytes available.
Sat Sep 22 04:24:24 2018
************************************************************************
You have following choices to free up space from recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
system command was used to delete files, then use RMAN CROSSCHECK and
DELETE EXPIRED commands.
************************************************************************

CAUSES

Standby database archive log retention policy is not configured properly.

RMAN> show all;
...
..
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE;
..

RESOLUTION

Change  the archive log retention policy on standby side.

RMAN>CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;

ORA-19816: WARNING: Files may exist in db_recovery_file_dest that are not known to database

Oracle database instance hung due to recovery area full causing “Archival Stopped Error”.

Check alert.log with below ORA errors:

— Alert.log

ORA-19816: WARNING: Files may exist in db_recovery_file_dest that 
           are not known to database.
ORA-17502: ksfdcre:4 Failed to create file +FRA
ORA-15041: diskgroup "FRA" space exhausted
*************************************************************
WARNING: A file of type ARCHIVED LOG may exist in
db_recovery_file_dest that is not known to the database.
Use the RMAN command CATALOG RECOVERY AREA to re-catalog
any such files. If files cannot be cataloged, then manually
delete them using OS command. This is most likely the
result of a crash during file creation.
*************************************************************

Check recovery area view , which says a lot of free space available:

SQL> set pagesize 120
SQL> set linesize 120
SQL> select * from v$recovery_area_usage;

FILE_TYPE    PERCENT_SPACE_USED  PERCENT_SPACE_RECLAIMABLE NUMBER_OF_FILES
-----------  ------------------- ------------------------- ---------------
...
..
ARCHIVED LOG               33.5                         0.8            248
BACKUP PIECE                0                           0                0
...
..
.
7 rows selected.

Check the database resetlog date and time:

SQL> alter session set nls_date_format='YYYYMMDD-HH24:MI:SS';

Session altered.

SQL> select CREATED,RESETLOGS_TIME,PRIOR_RESETLOGS_TIME,
            CONTROLFILE_TIME,VERSION_TIME from v$database;

CREATED           RESETLOGS_TIME    PRIOR_RESETLOGS_T CONTROLFILE_TIME  VERSION_TIME
----------------- ----------------- ----------------- ----------------- -----------------
20180817-11:05:10 20180817-11:05:43 20161009-20:55:02 20180821-15:19:21 20180817-11:05:10

CAUSE

There are archivelogs in recovery area from old databases, which were refreshed or restored with different DB ID, manually delete them, then everything is fine:

ASMCMD> ls -ltr
Type  Redund  Striped  Time             Sys  Name

                                        ...                                        ...
                                        ..
                                        .
                                        Y    2018_08_14/
                                        Y    2018_08_15/
                                        Y    2018_08_16/
           RESETLOGS DATE      ----->   Y    2018_08_17/
                                        Y    2018_08_18/
                                        Y    2018_08_19/
                                        Y    2018_08_20/