OraclePoolLab is a .NET 8+ console application that turns Oracle connection pooling assumptions into measurable, reproducible experiments. Investigate connection lifecycles, pool exhaustion, transaction enlistment, and performance characteristics in a safe, isolated environment.
🔗 Repository: PouyaBasiri/OracleLab
The Problem
Oracle connection pooling is powerful but misunderstood. Developers often ask:
- ❓ What happens when I open a connection and forget to dispose of it?
- ❓ How does
TransactionScopeinteract with the connection pool? - ❓ Why is my first query slow, but subsequent ones are fast?
- ❓ What does
ClearPoolactually do? - ❓ How do dead pooled connections behave?
These questions are hard to answer without hands-on experimentation. Reading documentation isn't enough—you need to see the pool in action.
The Solution: OraclePoolLab
OraclePoolLab provides eight reproducible scenarios that let you observe connection pooling behavior in real time, with diagnostics from Oracle's V$SESSION system view.
Key Scenarios
1. check — Verify Connectivity
Print ODP.NET and Oracle versions. Confirm your environment is set up correctly.
dotnet run -- check # Output: # ODP.NET assembly : 23.1.0.0 # Server version : 11.2.0.4.0 # Current user : APP_USER # Service name : MYSERVICE # Connection OK. 2. leak — Connection Leak Demonstration
Compare buggy code (leaked connections) with proper code (using await using).
Leaked code blocks the pool until connections timeout. Proper disposal recycles connections immediately.
// Buggy: Connection never returned to pool var conn = new OracleConnection(connStr); await conn.OpenAsync(); // Oops—no dispose! // Proper: Connection returned immediately await using var conn = new OracleConnection(connStr); await conn.OpenAsync(); // Connection recycled automatically 3. exhaust — Pool Exhaustion Under Slow Queries
Simulate a scenario where all pool connections are blocked by slow queries. Watch the pool deplete in real time without any leaks.
This demonstrates the difference between:
- Leaks (connections lost forever)
- Exhaustion (all connections temporarily in use)
4. clearpool — Understand ClearPool Behavior
Investigate what happens when you call OracleConnection.ClearPool() on:
- Idle connections (recycled)
- In-use connections (behavior varies by version)
5. scope — TransactionScope and Connection Retention
Does a TransactionScope keep the connection checked out, or is it released back to the pool?
Examine real behavior with actual timings:
using var scope = new TransactionScope(); await using var conn = new OracleConnection(connStr); await conn.OpenAsync(); // Connection remains checked out until scope.Complete() scope.Complete(); // Now connection is recycled 6. warmup — Cold vs. Warm Pool Performance
Compare startup performance:
- Cold pool: First request takes ~341 ms (from scratch)
- Warm pool: Pre-warmed with
Min Pool Size = 5takes ~4 ms
This shows the massive impact of connection pre-warming.
Cold pool first burst: 341 ms Warm pool first burst: 4 ms Speedup: 85x faster 7. deadconn — Dead Pooled Connections (Interactive)
Investigate what happens when a session is terminated on the server while the connection is in the pool.
This requires DBA privileges to kill a session, so it's interactive.
8. all — Run Everything
Execute all non-interactive scenarios in sequence:
dotnet run -- all Why This Matters
Connection pooling is invisible by default. When something goes wrong, the symptoms are vague:
- "The app hangs after a while"
- "It works fine the first time, but then slows down"
- "Database sessions keep piling up"
With OraclePoolLab, you can:
✅ Reproduce issues locally in a controlled environment
✅ Measure behavior with timing and session counts
✅ Verify assumptions before they bite you in production
✅ Learn pooling internals by running experiments
✅ Document findings for your team
Getting Started
Prerequisites
- .NET SDK 8.0+ (supports newer runtimes via RollForward)
- Oracle test database (not production!)
- Database account with
CREATE SESSIONprivilege
Optional for advanced scenarios:
-
SELECTonV$SESSIONfor session monitoring - DBA access for session termination (
deadconnscenario) - Procedure execution for sleep procedures (
exhaustscenario)
Configuration
Provide the Oracle connection string via environment variable:
PowerShell:
$env:ORACLE_CONNSTR = "User Id=your_user;Password=***;Data Source=your_host:1521/your_service" Bash / Zsh:
export ORACLE_CONNSTR='User Id=your_user;Password=***;Data Source=your_host:1521/your_service' Run an Experiment
# Clone and navigate to the project git clone https://github.com/PouyaBasiri/OracleLab.git cd OraclePoolLab # Verify connectivity dotnet run -- check # Run the connection leak scenario dotnet run -- leak # Compare cold vs. warm pool dotnet run -- warmup # Monitor sessions in real time dotnet run -- monitor Implementation Highlights
Session Tagging
All connections are tagged with MODULE = 'OraclePoolLab' so you can find them in V$SESSION:
SELECT SID, SERIAL#, USERNAME, MODULE, STATUS FROM V$SESSION WHERE MODULE = 'OraclePoolLab'; This makes it easy to monitor exactly which sessions belong to your experiment.
Separate Monitoring Connection
The monitor scenario uses a non-pooled connection to avoid consuming pool slots while observing the pool itself.
Thread Pool Tuning
The app configures minimum 64 threads to prevent thread-pool ramp-up effects from distorting performance measurements.
ThreadPool.SetMinThreads(64, 64); Real-World Scenarios
Scenario: Why is my app hanging after 20 minutes?
You might suspect a connection leak. Run:
dotnet run -- leak If it reproduces quickly at scale, you've likely found your issue. Check for missing using statements or proper DisposeAsync() calls.
Scenario: First query is slow, then it's fast
Classic cold-start issue! Run:
dotnet run -- warmup This demonstrates pre-warming with Min Pool Size. Add this to your connection string:
Min Pool Size=5; Scenario: Database says I have 500 sessions, but app only has 50 connections
You've got a leak or enlistment issue. Run:
dotnet run -- scope Understand how TransactionScope might be holding connections longer than you think.
What You'll Learn
After running OraclePoolLab scenarios, you'll understand:
📌 Connection Lifecycle
- How connections move from pool → in-use → back to pool
- What happens on disposal
📌 Pool Mechanics
- How distinct connection strings get distinct pools
- Why
Min Pool Sizematters for performance - What
Incr Pool SizeandDecr Pool Sizedo
📌 Transaction Behavior
- How
TransactionScopeaffects connection retention - When connections are enlisted and released
📌 Performance Characteristics
- Cold vs. warm pool startup times
- Impact of connection pre-warming
📌 Error Conditions
- Dead connection detection
- Pool exhaustion vs. connection leaks
Technology Stack
| Component | Technology |
|---|---|
| Runtime | .NET 8.0+ |
| Language | C# 11+ |
| Database Provider | Oracle.ManagedDataAccess.Core 23.x |
| Database | Oracle Database (11g+) |
| Diagnostics | Oracle V$SESSION view |
Safety & Limitations
✅ Safe: Designed for dedicated test databases
✅ Non-destructive: No application tables modified
✅ Observable: Sessions tagged for server-side inspection
⚠️ Test environment only — never run against production
⚠️ Version-dependent — behavior varies by Oracle and ODP.NET versions
⚠️ Requires privileges — some scenarios need DBA access
Next Steps
- Clone the repository: PouyaBasiri/OracleLab
- Run
dotnet run -- checkto verify connectivity - Pick a scenario that matches your concern (leak? performance? transactions?)
- Monitor with
dotnet run -- monitorin another terminal - Document findings for your team
Questions?
- 💬 What connection pooling scenarios would you like to investigate?
- 🐛 Found a bug or unexpected behavior? Open an issue!
- 🚀 Built on this idea? Share your extensions!
About the Project
OraclePoolLab turns vague pooling questions into measurable, reproducible experiments. It's designed for developers and DBAs who want to understand Oracle connection behavior before it causes production incidents.
Measure the behavior. Verify the assumptions. Understand the pool.
Last updated: 2026-11-30
Happy experimenting! 🚀

