Pages

Monday, May 20, 2019

Fatal NI connect error 12170. Inbound connection timed out (ORA-3136)

============================
General
============================
Why error ORA-3136 is coming in Oracle alert.log?

============================
Reference
============================
Per Oracle Technote #793259.1

ORA-1017 May Cause ORA-3136 WARNING : Inbound Connection Timed Out in Alert Log (Doc ID 793259.1)
The reason for the ORA-3136 error being thrown in the alert log is when a client fails to complete the authentication process in the time allowed by INBOUND_CONNECT_TIMEOUT.  
Very often, the 3136 error is actually the result of an ORA-01017 or "invalid username /password".  
When this error is returned to a client and, while at the same prompt, if incorrect credentials are supplied again OR no other attempt is made in under the 1 minute threshold (default), the instance will throw the message in the alert.log:   
WARNING: inbound connection timed out (ORA-3136)

To reproduce it:
inside sqlnet.ora parameter on the server add below parameter
SQLNET.INBOUND_CONNECT_TIMEOUT=60

Now open a SQL*Plus session and enter wrong username or password:

Keep the SQL*Plus session open for 60 seconds and in the alert log after 60th second , you will notice ORA-3136 in alert.log


============================
Example
============================

Edit sqlnet.ora, to override the 1 minute default:
SQLNET.INBOUND_CONNECT_TIMEOUT=120

my_user@my_server:~>% date
Mon May 20 08:01:49 GMT 2019
iu@my_server:~>% sqlplus system/xxx@orainst

SQL*Plus: Release 11.2.0.4.0 Production on Mon May 20 08:01:54 2019

Copyright (c) 1982, 2013, Oracle.  All rights reserved.

ERROR:
ORA-01017: invalid username/password; logon denied

Enter user-name:

<keep the sqlplus session open>
After 2 minutes, check inside alert.log


/software/oracle/diag/rdbms/orainst/orainst/trace>% less alert_orainst.log
Mon May 20 08:03:54 2019

********************************************************************
Fatal NI connect error 12170.

  VERSION INFORMATION:
        TNS for Linux: Version 11.2.0.4.0 - Production
        Oracle Bequeath NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
        TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.4.0 - Production
  Time: 20-MAY-2019 08:03:54
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12535

TNS-12535: TNS:operation timed out
    ns secondary err code: 12606
    nt main err code: 0
    nt secondary err code: 0
    nt OS err code: 0
  Client address: (ADDRESS=(PROTOCOL=tcp)(HOST=4444.3333.222.111)(PORT=40131))
WARNING: inbound connection timed out (ORA-3136)



Inside lsnr_orainst.log
20-MAY-2019 08:01:54 * (CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orainst)(CID=(PROGRAM=sqlplus)(HOST=my_server)(USER=iu))) * (ADDRESS=(PROTOCOL=tcp)(HOST=444.333.222.1111)(PORT=40131)) * establish * orainst * 0

============================
Conclusion
============================
Exactly as per Oracle technote...:

Connection was made at 08:01:54 with wrong credentials
sqlplus session was kept open for 2 minutes
After 2 minutes, there is ORA-3136 error in alert.log

Sunday, May 12, 2019

What Is Database Change Notification.

=======================
General
=======================
What Is Database Change Notification?
Database Change Notification is a feature that enables client applications to register queries with the database and receive notifications in response to DML or DDL changes on the objects associated with the queries. 
The notifications are published by the database when the DML or DDL transaction commits.

During registration, the application specifies a notification handler and associates a set of interesting queries with the notification handler. 
A notification handler can be either a server side PL/SQL procedure or a client side C callback. 
Registrations are created on all objects referenced during the execution of the queries. 
The notification handler is invoked when a transaction subsequently changes any of the registered objects and commits.

For example:
Let us assume that the application is interested in being notified about result set changes to a query on the HR.EMPLOYEES table. 
The application can register the query on the hr.employees table with the database using the Change Notification Feature. 
If a user adds an employee, then the application can receive a database change notification when a new row is added to the table. 
A new query of hr.employees returns the changed result set.

When the database issues change notification, it can contain some or all of the following information:

Names of the modified objects. 
For example, the notification can specify that the hr.employees table was changed.

The type of change. 
For example, the message specifies whether the change was caused by an INSERT, UPDATE, DELETE, ALTER TABLE, or DROP TABLE.

The ROWIDs of the changed rows and the type of DML that changed them.

Global events such as STARTUP and SHUTDOWN (consistent only). 

In a Real Applications Cluster, the database delivers a notification when the first instance on the database starts or the last instance shuts down.

The notification contains only metadata about the changed rows or objects rather than the changed data itself. 
For example, the database does not notify the client that a monthly salary increased from 5000 to 6000. 
To obtain more recent values for the changed objects or rows, the client must query the database based on the information contained in the notification.

Database Change Notification is useful for an application that caches query result sets on mostly read-only objects in the mid-tier to avoid network round trips to the database. 

Such an application can create a registration on the queries it is interested in caching using the change notification service. 
On changes to objects referenced inside those queries, the database publishes a change notification when the underlying transaction commits. 
In response to the notification, the application can refresh its cache by re-executing the queries.


For example, the users of a Web forum application may not need to view new content as soon as it is inserted into the back-end database. 
Such an application is intrinsically tolerant of slightly out-of-date data, and hence can benefit from caching in the mid-tier. 

Database change notification is of help in this scenario in keeping the cache updated with the back-end database.

=======================
Error: 
=======================
ORA-29972: user does not have privilege to change/ create registration

=======================
Solution:
=======================
GRANT CHANGE NOTIFICATION to USER_A ;

=======================
Reference
=======================
Developing Applications with Database Change Notification