Chapter 21 · Resource Manager, Workload Governance, Services, and Capacity Control

Services as Workload Boundaries for RAC/Data Guard/Applications and Operational Routing

Use Oracle database services as SLO and routing boundaries across PDBs, single-instance applications, RAC and Data Guard; verify service identity, draining/relocation expectations and client-pool observability.

Advanced120–140 minutesLocal service + RAC/Data Guard routing designDBMS_SERVICE Free-compatible; SRVCTL/Broker topology-gatedRESET_STATE noted for stateless poolsLast reviewed: August 2026

Learning outcomes

ServiceHub has three connection strings that differ only by host and SID. During maintenance, the DBA stops one instance and expects clients to “figure it out.” A database service should instead be the stable workload contract: it names the business class, carries service attributes, can be created in a PDB, can move among RAC instances, and can start only on the database role where the workload is valid.

01

Treat services as workload/SLO identity rather than aliases for SIDs/instances.

02

Create/verify a PDB-local service with DBMS_SERVICE on Free and observe SERVICE_NAME/MODULE/ACTION.

03

Connect service placement to RAC preferred/available instances and planned draining.

04

Connect services to Data Guard primary/standby roles without confusing database failover with client reconnection.

05

Design pool timeout/retry/FAN/Application Continuity expectations and use RESET_STATE for stateless session hygiene where appropriate.

Generation-time baseline, licensing, container, and tooling boundary

Mandatory examples target Oracle AI Database Free 26ai and were reviewed against RU 23.26.3, SQL Developer 26.2, and SQLcl 26.2.1. Free is limited to 2 foreground CPU cores, 2 GB combined SGA/PGA memory, 12 GB user data, and one installation per logical environment; Oracle provides no Release Update patches or Support service requests for Free. The course CDB/PDB baseline is FREE/FREEPDB1. Current 26ai licensing marks Database Resource Manager unavailable in Free and SE2-ODA, while it is available in EE/EE-ES and selected BaseDB/ExaDB offerings. Therefore DBMS_RESOURCE_MANAGER plan creation, activation, consumer-group mapping, active-session pools and automatic switching are entitlement-gated examples. The mandatory Free path uses real services, DBMS_APPLICATION_INFO/DBMS_SESSION instrumentation, V$SESSION/V$SYSSTAT evidence, controlled serial work and a governance-model table. Parallel query/DML is also unavailable in Free, so parallel-limit directives are taught only for entitled deployments. No AWR, ASH, Diagnostics Pack, Tuning Pack, RAC, Data Guard, or Enterprise Manager is required for the Free exercises.

1. A service is the application contract

Clients should request a service such as servicehub_oltp, not an instance SID. The service communicates what workload this is; Oracle/network/Clusterware can decide where it currently runs. This makes the same name useful for Resource Manager mapping, service statistics, RAC placement and Data Guard role routing.

2. Free lab: create a PDB-local service

sql · PDB administrator in FREEPDB1
BEGIN  BEGIN DBMS_SERVICE.STOP_SERVICE('servicehub_ch21_ops'); EXCEPTION WHEN OTHERS THEN NULL; END;  BEGIN DBMS_SERVICE.DELETE_SERVICE('servicehub_ch21_ops'); EXCEPTION WHEN OTHERS THEN NULL; END;  DBMS_SERVICE.CREATE_SERVICE(    service_name => 'servicehub_ch21_ops',    network_name => 'servicehub_ch21_ops'  );  DBMS_SERVICE.START_SERVICE('servicehub_ch21_ops');END;/SELECT name,network_name,pdbFROM v$servicesWHERE name='servicehub_ch21_ops';

When DBMS_SERVICE.CREATE_SERVICE runs in a PDB, the service is associated with that PDB. In a database managed by Oracle Restart/Clusterware, Oracle recommends managing services with SRVCTL instead.

3. Verify the client really used the service

text · SQLcl client
sql servicehub_app@//localhost:1521/servicehub_ch21_opsBEGIN  DBMS_APPLICATION_INFO.SET_MODULE('SERVICEHUB_OPS','HEALTH_CHECK');END;/SELECT  SYS_CONTEXT('USERENV','SERVICE_NAME') AS service_name,  SYS_CONTEXT('USERENV','CON_NAME') AS con_name,  SYS_CONTEXT('USERENV','INSTANCE_NAME') AS instance_nameFROM dual;
sql · admin/service observer
SELECT  service_name,  module,  action,  COUNT(*) AS sessionsFROM v$sessionWHERE type='USER'GROUP BY service_name,module,actionORDER BY service_name,module,action;

4. Deliberately wrong: hard-code an RAC node hostname/SID

If the client targets only racnode1, the database can remain available on node 2 while the application still cannot connect. RAC best practice is a service discovered through SCAN and managed by Clusterware. Planned maintenance relocates/drains the service before stopping an instance.

text · entitled RAC service shape
srvctl add service   -db servicehub_rac   -service servicehub_oltp   -pdb FREEPDB1   -preferred shrac1   -available shrac2   -policy AUTOMATIC   -notification TRUEsrvctl status service   -db servicehub_rac   -service servicehub_oltp   -verbose

5. Planned draining is different from failure recovery

text · entitled RAC planned relocation
srvctl relocate service   -db servicehub_rac   -service servicehub_oltp   -oldinst shrac1   -newinst shrac2   -drain_timeout 120   -stopoption TRANSACTIONAL

The drain timeout is workload-specific. During planned draining, new work should be directed away while eligible in-flight requests finish. An unplanned instance crash cannot grant that same drain window.

6. Data Guard services follow database roles

A Data Guard role transition changes which database is primary. Broker/startup triggers/Clusterware role-based services can ensure a writable service runs only on PRIMARY, while a reporting service may run on a read-capable standby when licensed. This is separate from redo transport/apply itself.

sql · entitled topology verification after transition
SELECT db_unique_name,database_role,open_modeFROM v$database;SELECT name,pdb,network_nameFROM v$servicesWHERE name LIKE 'servicehub%';

Clients still need valid connect descriptors/SCAN/listener/DNS endpoints and retry/failover behavior. Data Guard failover does not teleport an existing TCP session.

7. Connection failover versus request replay

Fast Application Notification (FAN)-aware pools can discard dead connections and create new ones on healthy service members. Application Continuity can replay eligible requests, but it has RAC/Active Data Guard/RAC One Node entitlement and driver/service requirements. Do not promise replay for arbitrary external side effects or unknown commit outcomes.

8. RESET_STATE improves stateless pooled-session hygiene in 26ai

As of 26ai, the service attribute RESET_STATE works independently of Application Continuity. For stateless applications, it can clear session state between requests and reduce leakage of contexts/package/session settings to the next pool borrower. Validate the exact driver/pool/service combination and do not enable it for applications that intentionally persist database session state between requests.

9. Services become Resource Manager mapping inputs on entitled systems

sql · entitled mapping pattern
BEGIN  DBMS_RESOURCE_MANAGER.CREATE_PENDING_AREA();  DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(    DBMS_RESOURCE_MANAGER.SERVICE_NAME,    'servicehub_oltp',    'SH21_OLTP');  DBMS_RESOURCE_MANAGER.SET_CONSUMER_GROUP_MAPPING(    DBMS_RESOURCE_MANAGER.SERVICE_NAME,    'servicehub_batch',    'SH21_BATCH');  DBMS_RESOURCE_MANAGER.VALIDATE_PENDING_AREA();  DBMS_RESOURCE_MANAGER.SUBMIT_PENDING_AREA();END;/

This creates one consistent vocabulary across connection routing, monitoring and resource governance.

10. Service SLO card

Service Role/topology Workload/SLO Failure behavior
servicehub_oltp Primary; RAC preferred/available Latency-sensitive requests FAN/reconnect; replay only if engineered
servicehub_batch Primary Bounded throughput Scheduler retry/resume after role transition
servicehub_analytics Primary or ADG read service if licensed Staleness/concurrency contract Fallback/queue according to freshness policy
servicehub_maint Admin-controlled Maintenance window No ordinary application routing

11. Cleanup

sql · Free PDB service cleanup
BEGIN  DBMS_SERVICE.STOP_SERVICE('servicehub_ch21_ops');  DBMS_SERVICE.DELETE_SERVICE('servicehub_ch21_ops');END;/

12. Production judgment

Name services by workload contract, not server name. Instrument every pooled request with module/action/client ID, test planned drain and unplanned failure separately, and verify the database role/service before accepting writes after Data Guard transitions. Keep connect timeouts/retries bounded and driver-specific.

DBMS_SERVICE local service creation is Free-compatible. RAC SRVCTL, FAN/SCAN and role placement require their topology/licensing; Application Continuity has explicit option prerequisites on EE/EE-ES. Lesson 5 consolidates all chapter mechanisms into one governance policy with emergency override and rollback.

Check your understanding

  1. Why is a service better than a SID as an application endpoint?
  2. Does service relocation preserve every in-flight transaction?
  3. What does a Data Guard role-based service solve?
  4. What does RESET_STATE address?
  5. Can a service name be used as a Resource Manager mapping attribute?
Review the answers

It names the workload/SLO independently of which instance currently hosts it.

No. Planned draining can reduce disruption, while failure breaks sessions; replay requires compatible engineered mechanisms.

It ensures the right workload service is available only on the database role where it is valid.

It clears leaked database session state between requests for stateless pooled applications.

Yes, on an entitled Resource Manager deployment.

Authoritative references

Keep knowledge open

Help the academy stay free and grow.

If these tutorials save you time, a small donation supports new lessons, technical review, diagrams, examples, and long-term maintenance.

ETHEthereum / ERC-20 only
0x716c4Ab160C4B66F31a28AE2448BfF68fc3a2ef0

Send only Ethereum or ERC-20 compatible assets to this address.