Wednesday, April 8, 2015

What happens in Standby after a nologging operation on Primary DB ?

https://community.oracle.com/thread/666455

1]In Primary, if a table "A" is in NOLOGGING, redo's are not generated(except the dictionary stuff) if INSERT is performed with "APPEND" hint. Isn't it?
(900 rows as inserted with append hint into A)

2]So if there is a standby, while the archive logs are applied the table "A" isn't populated with the data. (isn't it ?)

3]On Primary, if i "DELETE from A where id=3",
what would happen while that particular archive log is applied on the standby(which has the table but no data 'coz of nologging and append ?

What would happen if after step2, i open the standby in read only and perform
 select * from A; 
Will it through error? or give "no rows selected" ?

TIA,
JJ
Average User Rating: No ratings (0 ratings)
Average User Rating
No ratings
(0 ratings)
    • 1. Re: What happens in Standby after a nologging operation on Primary DB ?
      mbobakGrand Master
      JJ,

      I don't have standby db setup to test it, but I'm pretty sure you'll see ORA-26040 'data block was loaded with NOLOGGING option'. This is the same error you'd get on the primary if you did media recovery using a backup that was taken before the nologging operation.

      To avoid this, set force_logging to TRUE on your primary database.

      -Mark
      • 2. Re: What happens in Standby after a nologging operation on Primary DB ?
        639907Whiz
        Hi J.J,

        This is part of a material I'm preparing about this topic:

        Redo generation is a vital part of the Oracle recovery mechanism. Without it crashed instances will not recover and will not start in a consistent state. Excessive LOGGING is the result of excessive work on the database.

        The Oracle® Database Administrator's Guide 10g Release 2 say regarding the main benefits of the NOLOGGING option:

        •     Space is saved in the redo log files
        •     The time it takes to create the table is decreased
        •     Performance improves for parallel creation of large tables

        “A very important rule with respect to data is to never put yourselft into an unrecoverable situation. The importance of this guideline cannot be stressed enough, but it does not mean that you can never use time saving or performance enhancing options. “

        Oracle gave the user the ability to limit redo generation on tables and indexes by setting them in NOLOGGING mode. NOLOGGING affect the recoverability and before going into how to limit the redo generation it is important to clear the misunderstanding that NOLOGGING is the way out of redo generation, this are some points regarding it:

        •     NOLOGGING is designed to handle bulk inserts for data which can be re-produced.
        •     Writing to undo blocks causes generation of redo regardless of LOGGING status.
        •     LOGGING should not be disabled on a primary database if it has one or more standby databases. For this reason oracle introduced the ALTER DATABASE FORCE LOGGING command in Oracle 9i R2. This means that the NOLOGGING attribute will not have any effect on the segments if the database is in FORCE LOGGING MODE. NOLOGGING can be also override at tablespace level using ALTER TABLESPACE … FORCE LOGGING.
        •     Any change to the database dictionary will cause LOGGING. This will happen to protect the data dictionary. One example is if we allocated a space above the HWM for a table, and the system fail in the middle of one INSERT /*+ APPEND */ , the Oracle will need to rollback that data dictionary update. There will be redo generated but it is to protect the data dictionary, not your newly inserted data (Oracle just undo the space allocation if it fails, your data will disappear).
        •     Data which are not logged can not be recovered. The data should be backed up after the modification.
        •     Tables and indexes should be set back to LOGGING mode when the NOLOGGING is no longer needed.
        •     NOLOGGING is not needed for Direct Path Insert if the database is in NO Archive log mode.
        •     NOLOGGING should not be used for the data which can not be reproduced. If data which can not be reloaded was loaded using NOLOGGING and the database crashes before backing this data up, the data can not be recovered.
        •     NOLOGGING does not apply to UPDATE and DELETE.
        •     NOLOGGING will work during certain situations but subsequent DML will generate redo. Some of these situations are: direct load INSERT (using APPEND hint), CREATE TABLE ... AS SELECT, CREATE INDEX.
        •     If the LOGGING or NOLOGGING clause is not specified when creating a table, partition, or index the default to the LOGGING attribute will be the LOGGING attribute of the tablespace in which it resides.


        Disabling Logging (NOLOGGING)


        Logging can be disabled at the table level or the tablespace level. If it is done at the tablespace level then every newly created index or table in this tablespace will be in NOLOGGING mode you can have logging tables inside a NOLOGGING tablespace). A table or an index can be created with NOLOGGING mode or it can be altered using ALTER TABLE/INDEX NOLOGGING. It is important to note that just because an index or a table was created with NOLOGGING does not mean that redo generation has been stopped for this table or index. NOLOGGING is active in the following situations and while running one of the following commands but not after that. This is not a full list:

        •     DIRECT LOAD (SQL*Loader)
        •     DIRECT LOAD INSERT (using APPEND hint)
        •     CREATE TABLE ... AS SELECT
        •     CREATE INDEX
        •     ALTER TABLE MOVE
        •     ALTER TABLE ... MOVE PARTITION
        •     ALTER TABLE ... SPLIT PARTITION
        •     ALTER TABLE … ADD PARTITION (if HASH partition)
        •     ALTER TABLE … MERGE PARTITION
        •     ALTER TABLE … MODIFY PARTITION
        o ADD SUBPARTITON
        o COALESCE SUBPARTITON
        o REBUILD UNUSABLE INDEXES
        •     ALTER INDEX ... SPLIT PARTITION
        •     ALTER INDEX ... REBUILD
        •     ALTER INDEX ... REBUILD PARTITION


        Logging is stopped only while one of the commands above is running, so if a user runs this:

        •     ALTER INDEX new_index NOLOGGING.

        The actual rebuild of the index does not generate redo (all data dictionary changes associated with the rebuild will do) but after that any DML on the index will generate redo this includes direct load insert on the table which the index belongs to.

        Here is another example to make this point more clear:

        •     CREATE TABLE new_table_nolog_test NOLOGGING(….);

        All the following statements will generate redo despite the fact the table is in NOLOGGING mode:

        •     INSERT INTO new_table_nolog_test ...,
        •     UPDATE new_table_nolog_test SET …,
        •     DELETE FROM new_table_nolog_test ..

        The following will not generate redo (except from dictionary changes and indexes):

        •     INSERT /*APPEND/ …
        •     ALTER TABLE new_table_nolog_test MOVE …
        •     ALTER TABLE new_table_nolog_test MOVE PARTITION …

        To activate the NOLOGGING for one of the ALTER commands above add the NOLOGGING clause after the end of the ALTER command.

        For example:

        •     ALTER TABLE new_table_nolog_test MOVE PARTITION parti_001 TABLESPACE new_ts_001 NOLOGGING;

        The same applies for CREATE INDEX but for CREATE TABLE the NOLOGGING should come after the table name.

        Example:

        •     CREATE TABLE new_table_nolog_test NOLOGGING AS SELECT * FROM big_table;

        "It is a common mistake to add the NOLOGGING option at the end of the SQL (Because oracle will consider it an alias and the table will generate a lot of logging)."

        To user Direct Path Load in SQL*Loader you must run the $ORACLE_HOME/rdbms/admin/catldr.sql script before your first sqlldr is run in direct path mode. To run sqlldr in direct path mode use direct=true.

        Note: Even though direct path load reduces the generation of redo, it is not totally eliminated. That's because those inserts still generate undo which in turn generates redo.

        If there is an index on the table, and an +APPEND INSERT is made on the table, the indexes will produce redo. This can be circumvented by setting the index to unusable and altering the session's (before 10g you only can set this at session level, after 10g you also can set this parameter at instance level) skip_unusable_indexes to true (This doesn't apply to UNIQUE indexes.).

        Note: Please be free to comment or correct it.
        Regards,

        Francisco Munoz Alvarez
        • 3. Re: What happens in Standby after a nologging operation on Primary DB ?
          rayb12617Newbie
          I understand the process of nologging on a single operation on a primary database.

          I would like to know what happens when appliying redo to a standby database afet having performed such an operation on the primary (ex alter index ... NOLOGGING) and then performing normal updates.

          Will application of redo logs fail altogether? What would the error code be?
          Will application of redo logs fail only for the affected object? or tablespace?
          or will the logs get applied anyway and actually corrupt the stanby?

          Thanks

          RayB
          • 4. Re: What happens in Standby after a nologging operation on Primary DB ?
            mbobakGrand Master
            Hi Ray,

            Hmm...this thread is almost a year old....

            Anyhow, to answer your questions:
            RayB wrote:
            I understand the process of nologging on a single operation on a primary database.
            Hmm...I'm not sure you do....let me explain why I think that.
            I would like to know what happens when appliying redo to a standby database afet having performed such an operation on the primary (ex alter index ... NOLOGGING) and then performing normal updates.
            This isn't a valid example. Altering an index to nologging has no effect on normal DML on that index. All index updates will log. It would affect a rebuild, in that the rebuild would not log. But normal DML would be unaffected.

            But, suppose you altered a heap table to be nologging. What then? Well, still, normal DML would log, and there'd be no effect. If however, after setting nologging, you did a direct load insert, i.e., insert /*+ append */, then those changes would not be logged. However, block invalidation records are generated for those new blocks.
            Will application of redo logs fail altogether? What would the error code be?
            No, at redo application time, there would be no error.
            Will application of redo logs fail only for the affected object? or tablespace?
            Redo application will not fail.
            or will the logs get applied anyway and actually corrupt the stanby?
            Essentially, yes. The redo gets applied, but, that redo, instead of having the data changes that occurred on primary, have block invalidation records in them. So, the blocks are allocated to the table and marked as invalid. If/when you try to read them on the standby, you'll get ORA-26040.

            If you have concerns about this, you should consider enabling force logging.

            Hope that helps,

            -Mark
            • 5. Re: What happens in Standby after a nologging operation on Primary DB ?
              ajallenWhiz
              RayB,

              Since it appears you are using dataguard, please execute the following query and post the results here.

              SELECT FORCE_LOGGING FROM V$DATABASE;
              • 6. Re: What happens in Standby after a nologging operation on Primary DB ?
                rayb12617Newbie
                The answer is "NO".
                Thanks for the answer, I keep forgetting about the v$database object.

                RayB
                • 7. Re: What happens in Standby after a nologging operation on Primary DB ?
                  rayb12617Newbie
                  I meant an operation like "alter index [rebuild | move] nologging;" which I suspect will not log the rebuild operation but continue logging after the operation completes.

                  Otherwise, thanks for conferming that corruption will occur on the standby.

                  RayB
                  • 8. Re: What happens in Standby after a nologging operation on Primary DB ?
                    ajallenWhiz
                    You need to run ALTER DATABASE FORCE LOGGING; So that NOLOGGING will be ignored. Else your standby database can get corrupted by not seeing all changes made in the primary. See the entry by F.Munoz Alvarez, above.
                    • 9. Re: What happens in Standby after a nologging operation on Primary DB ?
                      user11204758Newbie
                      So what's the process if i need to failover to the standby database where nologging has been used in the primary database?
                      • 10. Re: What happens in Standby after a nologging operation on Primary DB ?
                        jgarryLegend
                        [url http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/scenarios.htm#i1015738]Buy more personal lubricant.
                        • 11. Re: What happens in Standby after a nologging operation on Primary DB ?
                          Hemant K ChitaleTitan
                          Joel,

                          I almost flagged your post as s_p_a_m until I looked at what the URL actually was !


                          Hemant K Chitale

                          Tuesday, April 7, 2015

                          ALTER SYTEM DISCONNECT vs ALTER SYSTEM KILL for currently connected sessions

                          Every once in a while, I come across a clause for a commonly-used SQL statement/command that I’ve lost touch with. Recently this happened to me while looking up some SQL commands regarding the ‘ALTER SYSTEM’ options in Oracle.
                          Normally, when we are required to end a user session manually, we turn to the ALTER SYSTEM KILL SESSION ‘,'’ command (with additional options as required). However, another potential choice in these situations is the DISCONNECT clause, which causes a session to be disconnected from the Oracle database after they have completed the current transaction (in effect, after they have committed or rolled back the current transactions in their session).         
                          A simple example to contrast this difference is provided below:
                          Session 1 (a simple update of an existing table, T1):
                          SQL> update t2 set object_id=object_id+1;
                          50317 rows updated.
                          SQL> select  min(sid) from v$mystat;
                            MIN(SID)
                            ———-
                                 136
                          Session 2:
                          SQL> select username, sid, serial# from v$session where sid=136;
                          USERNAME                              SID    SERIAL#
                          —————————— ———- ———-
                          NIRADJ                                136         56
                          SQL> alter system disconnect session ‘136,56’ post_transaction;
                          System altered.
                          Back in the first session, we would see the following when we issue a ROLLBACK or COMMIT:
                          SQL> select  min(sid) from v$mystat;
                            MIN(SID)
                            ———-
                                 136
                          SQL> rollback;
                          Rollback complete.
                          SQL> select  min(sid) from v$mystat;
                          select  min(sid) from v$mystat
                          *
                          ERROR at line 1:
                          ORA-00028: your session has been killed
                          Now, contrast this with a typical ALTER SYSTEM KILL SESSION:
                          Session 1:
                          SQL> update t2 set object_id=object_id+1;
                          50317 rows updated.
                          SQL> select  min(sid) from v$mystat;
                            MIN(SID)
                            ———-
                               137
                          Session 2:
                          SQL> select username, sid, serial# from v$session where sid=137;
                          USERNAME                              SID    SERIAL#
                          —————————— ———- ———-
                          NIRADJ                                137         92
                          SQL> alter system kill session ‘137,92’;
                          System altered.
                          Back in the first session we would see the following:
                          SQL> select  min(sid) from v$mystat;
                          select  min(sid) from v$mystat
                          *
                          ERROR at line 1:
                          ORA-00028: your session has been killed
                          So here even though the current session has an active transaction, we see that the database has directly disconnected them, without the current transaction being finalized (either committed or rolled back) by the user. Instead, the database has automatically rolled back everything that was uncommitted in the background.

                          Sunday, March 29, 2015

                          Problem :

                          Sun Mar 29 17:47:42 2015
                          ARC0: Attempting destination LOG_ARCHIVE_DEST_2 network reconnect (3113)
                          ARC0: RFS network connection re-established at host 'pbldg'
                          ARC0: Archive log rejected (thread 1 sequence 4898) at host 'pbldg'
                          FAL[server, ARC0]: FAL archive failed, see trace file.
                          ARCH: FAL archive failed. Archiver continuing
                          ORACLE Instance pbldb1 - Archival Error. Archiver continuing.
                          Sun Mar 29 18:00:00 2015


                          ############################################################################

                          It is definitely not an archiving file system full. If it was the case then you would see archiver stuck messages in the alert log.
                          This is due to a bug and Oracle suggests to ignore these messages appearing in the Alert log as long as the Primary and Standby are in sync.

                          RC3: Archive log rejected (thread 1 sequence 136480) at host '(DESCRIPTION=  (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.26)(PORT=1530))(CONNECT_DATA=(SERVICE_NAME=sdbinfo)(SERVER=DEDICATED)))'
                          Errors in file /opt/dbinfo/diag/rdbms/dbinfo/dbinfo/trace/dbinfo_arc3_7445.trc:
                          ORA-16401: archivelog rejected by RFS
                          FAL[server, ARC3]: FAL archive failed, see trace file.
                          Errors in file /opt/dbinfo/diag/rdbms/dbinfo/dbinfo/trace/dbinfo_arc3_7445.trc:
                          ORA-16055: FAL request rejected
                          ARCH: FAL archive failed. Archiver continuing
                          ORACLE Instance dbinfo - Archival Error. Archiver continuing.

                          - RedoLog switch happens very frequently before the above Error reported
                          - The requested ArchiveLog by FAL requests the current Log Sequence or the Sequence currently being archived
                          Changes

                          The Problem here is that the Primary Database is switching Logs too frequently.

                          Using ARCH to send the archives, every time there's a log switch the Primary has to send the Archivelog to the Standby, meanwhile another Log Switch occurred on the Primary which causes also another Archivelog to be sent to the Standby, but the first one has not finished yet, a GAP is formed and detected by the Standby. At this Time the first Archivelog is also sent as FAL Request, but this one will fail because the first one is still being archiving, locked, so the second one fails.

                          Solution

                              Ignore these Messages as long as the Standby Database keeps synchronized with the Primary
                              Database Increase the Size of the Online Redologs to reduce Redolog Switch Frequency
                              Increase Network Bandwith between the Primary and Standby Database


                          Source : http://scn.sap.com/thread/3351294

                          Saturday, March 28, 2015

                          12170 TNS-12535/TNS-00505: Operation Timed Out error on alert log after Firewall Implementation



                          Alert Log Errors: 12170 TNS-12535/TNS-00505: Operation Timed Out (Doc ID 1628949.1)
                          Description: https://support.oracle.com/epmos/adf/images/t.gif


                          Description: https://support.oracle.com/epmos/adf/images/t.gif
                          In this Document







                          APPLIES TO:
                          Oracle Net Services - Version 11.2.0.3 to 12.1.0.1 [Release 11.2 to 12.1]
                          Information in this document applies to any platform.
                          SYMPTOMS
                          The following error is reported in the database alert log. 
                          ***Note the "Client address" is posted within the error stack in this case.

                          Fatal NI connect error 12170.

                          VERSION INFORMATION:
                          TNS for 64-bit Windows: Version 11.2.0.3.0 - Production
                          Oracle Bequeath NT Protocol Adapter for 64-bit Windows: Version 11.2.0.3.0 - Production
                          Windows NT TCP/IP NT Protocol Adapter for 64-bit Windows: Version 11.2.0.3.0 - Production
                          Time: 22-FEB-2014 12:45:09
                          Tracing not turned on.
                          Tns error struct:
                          ns main err code: 12535

                          TNS-12535: TNS:operation timed out
                          ns secondary err code: 12560
                          nt main err code: 505

                          TNS-00505: Operation timed out
                          nt secondary err code: 60
                          nt OS err code: 0
                          ***Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=121.23.142.141)(PORT=45679))
                            
                          The PORT field here is the ephemeral port assigned to the client for this connection.
                          This does not correspond to the listener port.

                          CHANGES
                          No changes are necessary, but may have recently upgraded the database to 11g release 1 or higher, or installed a new Oracle11g database and they are now visible in the alert log.
                          Note: Prior to 11gR1 these same 'Fatal NI connect error 12170' are written to the sqlnet.log.   This document describes a problem that arises when a firewall exists between the client and the database server.
                          CAUSE
                          We can search the listener log covering the same time period using this search criteria.
                           (HOST=121.23.142.141)(PORT=45679)

                          The 11g listener log in text format is located here:
                          $ORACLE_BASE/diag/tnslsnr///trace/.log

                          Again, this is the client's IP address and the unique ephemeral port assigned to the client for this connection.
                          In this case, we find that this connection was established at the listener at this timestamp:  

                          22-FEB-2014 10:42:10 * (CONNECT_DATA=(SID=test)(CID=(PROGRAM=)(HOST=__jdbc__)(USER=))) * (ADDRESS=(PROTOCOL=tcp)(HOST=121.23.142.141)(PORT=45679)) * establish * test* 0 .
                          Compare this to the event in the alert.log with special attention to the timestamp.
                          The connection was dropped by the instance at 22-FEB-2014 12:45:09 or roughly 2 hours later.
                          Time: 22-FEB-2014 12:45:09
                          Tracing not turned on.
                          Tns error struct:
                          ns main err code: 12535

                          TNS-12535: TNS:operation timed out
                          ns secondary err code: 12560
                          nt main err code: 505

                          TNS-00505: Operation timed out
                          nt secondary err code: 60
                          nt OS err code: 0
                          ***Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=121.23.142.141)(PORT=45679))
                          The 'nt secondary err code' identifies the underlying network transport, such as (TCP/IP) timeout limit. In the current case 60 identifies Windows underlying transport layer.
                          The "nt secondary err code" will be different based on the operating system:
                          Linux x86 or Linux x86-64: "nt secondary err code: 110"
                          HP-UX : "nt secondary err code: 238"
                          AIX: "nt secondary err code: 78"
                          Solaris: "nt secondary err code: 145"

                          The alert.log message indicates that a connection was terminated AFTER it was established to the instance.  In this case, it was terminated 2 hours and 3 minutes after the listener handed the connection to the database. 
                           This would indicate an issue with a firewall where a maximum idle time setting is in place. 
                          The connection would not necessarily be "idle".  This issue can arise during a long running query or when using JDBC Thin connection pooling.  If there is no data 'on the wire' for lengthy
                          periods of time for any reason, the firewall might terminate the connection.

                          SOLUTION
                          The non-Oracle solution would be to remove or increase the firewall setting for maximum idle time.  In cases where this is not feasible, Oracle offers the following suggestion:

                          The following parameter, set at the **RDBMS_HOME/network/admin/sqlnet.ora, can resolve this kind of problem.  DCD or SQLNET.EXPIRE_TIME can mimic data transmission between the server and the client during long periods of idle time.

                          SQLNET.EXPIRE_TIME=n  Where is a non-zero value set in minutes.


                          See the following : Note 257650.1 Resolving Problems with Connection Idle Timeout With Firewall

                          **In an installation that includes GRID, this parameter should be set in the RDBMS_HOME/network/admin/sqlnet.ora file.  This would be the default location for sqlnet.ora file parameters referenced by the instance. 


                          Please consider your business requirement for allowing connections to remain or appear 'idle' before implementing these suggestions.
                          REFERENCES
                          NOTE:257650.1 - Resolving Problems with Connection Idle Timeout With Firewall
                          NOTE:1286376.1 - Fatal NI Connect Error 12170, 'TNS-12535: TNS:operation timed out' Reported in 11g Alert Log



                          Doc ID 1335630.1
                          Doc ID 1286376.1

                          configuration on ODA :

                          [oracle@primoda1 ~]$ cat /u01/app/oracle/product/11.2.0.3/dbhome_1/network/admin/sqlnet.ora 
                          SQLNET.EXPIRE_TIME=10
                          SQLNET.INBOUND_CONNECT_TIMEOUT=2000
                          DIAG_ADR_ENABLED = OFF
                          DIAG_ADR_ENABLED_LISTENER = OFF