HA & DR

ORA-12516 and ORA-00020: The App Server Came Back. Its Old Connections Never Left.

· 11 min read

The hypervisor host under app server 1 dies at 2 a.m. The VM restarts on another host a few minutes later, comes back under the same name, opens its connection pool, and most of the pool fails:

ORA-12516: Cannot connect to database. Listener at host 172.28.0.2 port 1521
does not have a protocol handler for tcp ready or registered for service
FREEPDB1. (CONNECTION_ID=YbzFKf/eAVvgYwMAHKwo8w==)

The database is up. The listener is up. Nothing changed in the configuration. The DBA searches the logs for ORA-00020: maximum number of processes, the error every runbook says belongs here, and no application has it, because no application ever received it. The alert log has it once, and then stops writing it for a minute.

This post walks through a connection storm on Oracle AI Database 26ai from both sides: what the application sees, what the database records, why PROCESSES can’t simply be raised, and why that app server couldn’t get its pool back: its old connections, from before the crash, were still in the database. Every number comes from a lab on Oracle Database Free 26ai that you can run yourself.

Every connection is a process

With the default dedicated server, every connection gets its own server process, and PROCESSES caps them for the whole instance, every PDB included. SESSIONS is derived from it:

ParameterLab valueNotes
PROCESSES200instance-wide; “Modifiable: No”
SESSIONS322derived: 1.5 × PROCESSES + 22; can be lowered per PDB
processes in use before any user connectsabout 90the background processes

So the application didn’t have 200 processes, it had about 110. That’s the number to compare with the sum of the maximum pool sizes of every app server, batch job and tool that connects, plus room for the DBA. Three app servers with a pool of 50 each don’t fit.

V$RESOURCE_LIMIT shows where you are, including the high-water mark since startup:

SELECT resource_name, current_utilization, max_utilization, limit_value
FROM   v$resource_limit
WHERE  resource_name IN ('processes', 'sessions');

What the application sees

The lab fired 150 logins at once through the listener, each holding its session for 15 seconds:

    109 CONNECTED
     31 ORA-12516
     10 ORA-12537

No client got ORA-00020. Most got ORA-12516 from the listener; the others got ORA-12537: TNS:connection closed after the listener had accepted them. The listener log recorded TNS-12516, plus TNS-12518 (“listener could not hand off client connection”) and TNS-12547 for the closed ones.

The database side recorded it once:

ORA-00020: exceeded maximum number of processes specified in initialization parameter
 ORA-20 errors will not be written to the alert log for
 the next minute. Please look at trace files to see all
 the ORA-20 errors.

So alerting on ORA-00020 in application logs finds nothing, and alerting on it in the alert log finds one line per minute however many logins fail. When the lab ran two storms back to back, the second added no alert log line at all; only its trace files had ORA-00020. Alert on ORA-12516 and ORA-12537 in the application, and on V$RESOURCE_LIMIT approaching LIMIT_VALUE in the database.

Can the DBA still get in?

With the instance full, the lab tried each way in:

LoginResult
SYSTEM through the listenerORA-12537
local sqlplus / as sysdba (bequeath, no listener)got in
six more local SYSDBA loginsfive got ORA-00020
sqlplus -prelim / as sysdbaconnects; no SQL, but oradebug works

Logins through the listener stopped a couple of processes short of the limit, and a local SYSDBA login took one of the last slots. That’s one DBA, logged in on the database host, not a team on their laptops. If your recovery plan is “connect from SQL Developer and kill sessions”, it won’t work during the storm. Keep a way onto the host, and keep the kill script there.

PROCESSES can’t be raised online, whatever V$PARAMETER says

The obvious fix is a bigger PROCESSES. On 26ai Free 23.26.3, V$PARAMETER says you can:

NAME        ISSYS_MODIFIABLE
processes   IMMEDIATE

You can’t. Every online change failed, raising it, lowering it, and even setting it to the value it already had:

SQL> alter system set processes = 300 scope = memory;
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-02095: specified initialization parameter cannot be modified

The reference agrees with the error, not with the view: “Modifiable: No”. The change goes to the spfile and takes effect at the next restart:

ALTER SYSTEM SET processes = 300 SCOPE = SPFILE;
-- restart the instance (in the lab: 4–5 s; on a production system, plan it)

After the restart PROCESSES was 300 and SESSIONS had derived itself to 472. The same 150-login storm then got in completely, 150 of 150, which also proves the failures before were the process limit and not the burst itself.

Size it before you need it. A restart in the middle of an outage is a second outage.

The app server crashed. Its connections didn’t leave.

This is the storm that looks impossible. An app server with an 80-connection pool goes down hard: a kernel panic, a VM that’s killed, a network partition. Nothing closes its TCP connections. In the lab, appsrv1 opened 80 idle connections, and then its network was cut and the container killed.

A minute later all 80 sessions were still in V$SESSION, INACTIVE, waiting for a client that no longer existed. The app server came back under the same name and opened its pool:

restarted appsrv1:   27 CONNECTED
restarted appsrv1:   43 ORA-12516
restarted appsrv1:   10 ORA-12537

Now V$SESSION showed 107 sessions from machine appsrv1, and only 27 of them were real. The machine name doesn’t tell them apart. The logon time does:

SELECT machine, TO_CHAR(logon_time, 'HH24:MI') logon_minute, COUNT(*)
FROM   v$session
WHERE  username = 'APP'
GROUP  BY machine, TO_CHAR(logon_time, 'HH24:MI')
ORDER  BY 1, 2;
appsrv1   15:09   80    <- from before the crash
appsrv1   15:10   27    <- the restarted pool

Killing by logon time works. ALTER SYSTEM KILL SESSION ... IMMEDIATE on the sessions that logged on before the crash freed their 80 processes (197 down to 117 in one run) and left the restarted pool’s live sessions alone. In some runs a few of the kills raised an error and those sessions took a second pass, so check the count after killing, and repeat.

And the control: when the lab then stopped appsrv1 normally, its live sessions disappeared at once. An application that exits, even one that’s killed, has its sockets closed by the operating system while the host is still up, and the database notices. Only a crash that takes the host or the network with it leaves sessions behind.

How a login can fail when processes run out. The application sees listener errors; ORA-00020 reaches only a local login and the alert log. A crashed app server's sessions keep their processes until something kills them.

Dead connection detection, and the connections it doesn’t cover

The database-side fix for ghosts is dead connection detection: SQLNET.EXPIRE_TIME, in minutes, in the server’s sqlnet.ora (see the sqlnet.ora reference). The server probes idle connections, and when a probe finds the client gone, the server process exits. The same setting keeps idle connections alive through a firewall, which is how the ORA-03113 idle-connection post used it; in that lab, orphan sessions without it stayed for more than 30 minutes.

The lab made two pools, then crashed both:

PoolConnectedAfter the crash
appsrv2, 20 connectionsbefore EXPIRE_TIME = 1 was addedall 20 still there after 180 s
appsrv3, 20 connectionsafterall 20 gone after 127–128 s

Two things to take from that. With EXPIRE_TIME = 1 the cleanup took about two minutes, not one. And it covered only the connections made after it was added: the 20 that were already connected stayed, with no end in sight. Adding it during an incident does nothing for the ghosts you already have; kill those, and let the setting protect the next crash.

Capping one PDB, and the errors it gives

PROCESSES is shared by every PDB. One misbehaving application can take all of them and lock out the others. The lever inside a PDB is SESSIONS, which can be lowered for that PDB only:

ALTER SESSION SET CONTAINER = FREEPDB1;
ALTER SYSTEM SET sessions = 60;

With 120 logins at once against the capped PDB, 60 got in, and the instance kept its headroom: processes stayed at 146 of 200 while the cap held. But look at what the other 60 got:

     35 ORA-12523: TNS:listener could not find instance appropriate for the client connection
     17 ORA-28547: connection to server failed, probable Oracle Net admin error
      8 ORA-12516

The reference says exceeding a PDB’s SESSIONS generates ORA-00018. No client saw it. The alert log wrote one ORA-00018 line in some runs and none in others, so it isn’t a signal you can count on. An on-call engineer who reads “probable Oracle Net admin error” will go and check the listener, not the session count.

The cap also applies to the DBA: SYSTEM through the listener to the capped PDB got ORA-12523. The CDB root still accepted SYSTEM, and a SYSDBA in the root could switch into the PDB with ALTER SESSION SET CONTAINER. Note that in your runbook next to the cap.

A runbook for the storm

During:

  1. Log in locally on the database host: sqlplus / as sysdba. If even that fails with ORA-00020, sqlplus -prelim / as sysdba still connects, without SQL but with oradebug.
  2. Find who holds the processes: V$SESSION grouped by MACHINE, PROGRAM and logon minute. A machine with more sessions than its pool size, or sessions older than its last restart, has ghosts.
  3. Kill the ghosts, and only the ghosts: ALTER SYSTEM KILL SESSION 'sid,serial#' IMMEDIATE for that machine’s sessions that logged on before the crash. Let a failed kill pass, check the count, and repeat.

After:

  1. Do the arithmetic. Background processes, plus the maximum pool size of every app server, batch job and tool, plus headroom for the DBA and for an app server that restarts while its old sessions are still there. If that’s more than PROCESSES, raise it in the spfile at the next window, or shrink the pools.
  2. Set SQLNET.EXPIRE_TIME in the server’s sqlnet.ora. Oracle recommends 10 minutes; use less than any firewall idle timeout between the app servers and the database.
  3. Alert on the right signals: ORA-12516 and ORA-12537 in application logs, and V$RESOURCE_LIMIT for processes approaching its limit.
  4. Consider a PDB SESSIONS cap for applications that share a CDB, and document the errors it produces.

Prove it

The lab runs Oracle AI Database 26ai Free (23.26.3), plus short-lived client containers from the same image as “app servers” that open many SQL*Plus connections through the listener:

drill    case                                                   result
storm    150 logins at once, PROCESSES = 200                    109 in; ORA-12516 x31, ORA-12537 x10; no ORA-00020
                                                                at the client; ORA-00020 in the alert log
dba      instance full: SYSTEM via listener / local SYSDBA      ORA-12537 / in
         six more local SYSDBA; sqlplus -prelim                 5 x ORA-00020; connects
raise    ALTER SYSTEM SET processes (300, 200, 150)             ORA-02095 each (V$PARAMETER: IMMEDIATE)
         SCOPE = SPFILE + restart                               300, SESSIONS 472; the storm: 150 of 150 in
ghosts   80 idle connections, crash, a minute later             80 sessions still there
         same host restarts its pool of 80                      27 in; ORA-12516 x43, ORA-12537 x10
         KILL SESSION IMMEDIATE on the pre-crash sessions only  80 processes freed; live sessions stay
         then a normal stop of the app server                   its live sessions gone at once
dcd      crash; connected before / after EXPIRE_TIME = 1        still there at 180 s / gone at 128 s
pdbcap   PDB SESSIONS = 60, 120 logins at once                  60 in, processes 146 of 200; ORA-12523 x35,
                                                                ORA-28547 x17, ORA-12516 x8; no ORA-00018
         SYSTEM via listener to the PDB / to the root           ORA-12523 / in; SYSDBA can switch into the PDB

Don’t take my word for it — run it. The connection-storm lab asserts every row: the client errors and the absence of ORA-00020 at the client, the local SYSDBA login on a full instance, the ORA-02095 on every online change and the 150-of-150 control after the restart, the ghost sessions that survive a crash and block the restarted pool, the two EXPIRE_TIME pools, and the PDB cap’s errors. If any of it doesn’t reproduce, the run fails. Proven on every CI push.

What the lab doesn’t cover: shared server and Database Resident Connection Pooling (DRCP), which change the one-process-per-connection arithmetic; JDBC, ODP.NET and python-oracledb pools and their own validation and timeout settings; and RAC.

What teams get wrong

  • Searching the application logs for ORA-00020. The application gets ORA-12516 or ORA-12537. ORA-00020 is in the alert log, at most once a minute.
  • Counting PROCESSES as connections. About 90 of the lab’s 200 were background processes before anyone connected.
  • Planning to raise PROCESSES during the incident. It fails with ORA-02095, whatever V$PARAMETER says. It takes the spfile and a restart.
  • Restarting the crashed app server and expecting its pool back. Its old sessions are still there, under the same machine name, holding processes.
  • Adding EXPIRE_TIME to clean up existing ghosts. It covers only connections made after it’s set. Kill the existing ones.
  • Relying on a remote login to fix it. Through the listener even SYSTEM was refused. Keep host access.
  • Capping a PDB without telling on-call. The errors say “listener” and “Net admin error” (ORA-12523, ORA-28547, sometimes ORA-12516), not “too many sessions”.

Frequently asked questions

What does ORA-00020 maximum number of processes exceeded mean?

The instance has as many processes as its PROCESSES parameter allows, so a new server process can't start. With dedicated server every connection needs its own process, and the background processes count too: in the companion lab, about 90 of PROCESSES = 200 were in use before any user connected. Clients connecting through the listener usually don't see ORA-00020 itself; in the lab they got ORA-12516 or ORA-12537, and ORA-00020 appeared only in the alert log and for local logins.

Why does my application get ORA-12516 when the database is up?

ORA-12516 'Listener ... does not have a protocol handler for tcp ready or registered for service' often means the instance has run out of processes and the listener has stopped handing it new connections. In the companion lab, 150 logins at once against PROCESSES = 200 gave 109 connections, 31 ORA-12516 and 10 ORA-12537; with PROCESSES = 300 the same 150 logins all succeeded. Check V$RESOURCE_LIMIT for processes.

Can I increase PROCESSES without restarting the database?

No. In the companion lab on Oracle AI Database 26ai Free 23.26.3, ALTER SYSTEM SET processes failed with ORA-02097 and ORA-02095 for every value, including the current one, even though V$PARAMETER shows ISSYS_MODIFIABLE = IMMEDIATE. The Oracle reference lists PROCESSES as 'Modifiable: No'. Set it with SCOPE = SPFILE and restart; SESSIONS and TRANSACTIONS are derived from it unless set explicitly.

How can a DBA log in when the database has hit ORA-00020?

Locally on the database host. In the companion lab, with the instance full, SYSTEM through the listener got ORA-12537, but a local 'sqlplus / as sysdba' still got in: logins through the listener had stopped a few processes short of the limit. Further local logins got ORA-00020. 'sqlplus -prelim / as sysdba' connected even then, without SQL but with oradebug.

Why are sessions from a crashed application server still in the database?

Because nothing closed their TCP connections: the server process waits for a message from a client that no longer exists. In the companion lab an app server with 80 idle connections was cut off the network and killed; all 80 sessions were still there a minute later, and when it restarted, only 27 of its 80 new connections got in. An application that exits normally, or is killed while its host stays up, has its connections closed by the operating system and leaves nothing behind.

Does SQLNET.EXPIRE_TIME remove dead sessions that already exist?

Not in the companion lab: dead connection detection covered only connections made after EXPIRE_TIME was added to the server's sqlnet.ora. In the lab, after a crash, 20 sessions connected after EXPIRE_TIME = 1 was set were gone about 2 minutes later (127 to 128 seconds), while 20 connected before it were all still there after 180 seconds. Kill the existing ones with ALTER SYSTEM KILL SESSION ... IMMEDIATE.

What error do clients get when a PDB's SESSIONS limit is reached?

Not ORA-00018. In the companion lab, with SESSIONS = 60 set in the PDB, 120 logins through the listener gave 60 connections and the rest failed with ORA-12523 'TNS:listener could not find instance appropriate for the client connection', ORA-28547 'connection to server failed, probable Oracle Net admin error' and a few ORA-12516. SYSTEM through the listener couldn't reach the PDB either; a SYSDBA in the CDB root could switch into it.

A connection storm is arithmetic that nobody did: background processes plus every pool at its maximum, plus the sessions a crashed app server left behind, against a limit that only changes with a restart. Do the arithmetic, size PROCESSES before you need it, set EXPIRE_TIME so crashes clean up after themselves, and keep a way onto the database host for the day the listener says no. Then prove it with the connection-storm lab.

Have a question or some feedback?

I write here in a personal capacity and enjoy comparing notes with other Oracle folks. Say hello.

Get in touch