microsoft / microsoft/aspire

[tests] Oracle EF Core Tests Hang During Container Initialization

Open
#12,036 1 comment 0 reactions 0 assignees View on GitHub
needs-area-label oracle testing ☑️
Dominant language
C#
Stars
6.3k
Forks
991
Avg merge
2d 15h
Merged PRs (30d)
196

Description

# Oracle EF Core Tests Hang During Container Initialization

## Summary
The `Aspire.Oracle.EntityFrameworkCore.Tests` test suite is experiencing a hang during test collection initialization, specifically when starting the Oracle Docker container. The hang occurs during the wait strategy phase, where the test waits for the Oracle container to log the startup completion message.

## Test Run Information
- **Test Run URL**: https://github.com/dotnet/aspire/actions/runs/18514118920?pr=12019
- **Dump File**: `Aspire.Oracle.EntityFrameworkCore.Tests_2893_hang.dmp`
- **Target Framework**: net9.0
- **Platform**: ubuntu-latest (x64)
- **Hang Duration**: 7 minutes (triggered hang dump timeout)
- **Exit Code**: 7 (test application didn't exit gracefully)

## Root Cause Analysis

### 1. Call Stack Analysis
Using `dotnet dump analyze`, the async state shows the test is stuck in the following call chain:

```text
OracleContainerFixture.InitializeAsync()
└─> DockerContainer.StartAsync()
└─> DockerContainer.UnsafeStartAsync()
└─> DockerContainer.CheckReadinessAsync()
└─> WaitStrategy.WaitUntilAsync()
└─> Task.Delay (3,600,000ms = 1 hour timeout)
└─> Waiting for log: "Completed: ALTER DATABASE OPEN"
```

### 2. Thread State
- **Main Thread (0)**: Blocked in `XunitAutoGeneratedEntryPoint.Main()` waiting for test completion
- **Multiple Threadpool Workers**: Idle, waiting for work
- **Socket Async Thread**: Running but waiting for I/O events
- **ResourceReaper Thread**: Maintaining connection to Ryuk (Testcontainers cleanup service)

### 3. Container Configuration
From `OracleContainerFixture.cs`:
```csharp
Container = new OracleBuilder()
.WithPortBinding(1521, true)
.WithHostname("localhost")
.WithImage($"{ComponentTestConstants.AspireTestContainerRegistry}/gvenzl/oracle-xe:21.3.0-slim-faststart")
.WithWaitStrategy(Wait
.ForUnixContainer()
.UntilMessageIsLogged("Completed: ALTER DATABASE OPEN")
).Build();
```

### 4. Timer Analysis
The dump shows a `System.Threading.Tasks.Task+DelayPromise` with:
- `_dueTime`: 3,600,000 ms (1 hour)
- `_period`: 4,294,967,295 (UINT32_MAX - no repeat)
- `_startTicks`: 184,954

This indicates the wait strategy has a 1-hour timeout, but the hang dump was triggered after 7 minutes.

## Issue Details

The Oracle container (`gvenzl/oracle-xe:21.3.0-slim-faststart`) is not completing its startup sequence within a reasonable time. The test is waiting for the container to log the message `"Completed: ALTER DATABASE OPEN"`, which never appears.

**Possible causes:**
1. The Oracle container may be failing to start in the CI environment
2. The container may be starting but not logging the expected message
3. Docker resource constraints in the CI environment may be preventing container startup
4. The container image may be inaccessible or corrupted
5. There may be networking issues preventing proper container initialization

## Impact
- Tests cannot complete successfully
- CI pipeline is blocked for 7+ minutes before timeout
- All tests in the `Oracle Database collection` are affected

## Related Code
```csharp
public async ValueTask InitializeAsync()
{
if (RequiresDockerAttribute.IsSupported)
{
Container = new OracleBuilder()
.WithPortBinding(1521, true)
.WithHostname("localhost")
.WithImage($"{ComponentTestConstants.AspireTestContainerRegistry}/gvenzl/oracle-xe:21.3.0-slim-faststart")
.WithWaitStrategy(Wait
.ForUnixContainer()
.UntilMessageIsLogged("Completed: ALTER DATABASE OPEN")
).Build();

await Container.StartAsync();
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.