Skip to content

Commit b0ad014

Browse files
committed
dotnet10
1 parent 89abab9 commit b0ad014

File tree

7 files changed

+37
-69
lines changed

7 files changed

+37
-69
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [ main ]
88

99
env:
10-
DOTNET_VERSION: '9.0.x'
10+
DOTNET_VERSION: '10.0.x'
1111
SOLUTION_FILE: GraphRag.slnx
1212

1313
jobs:

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- cron: '0 0 * * 1'
1010

1111
env:
12-
DOTNET_VERSION: '9.0.x'
12+
DOTNET_VERSION: '10.0.x'
1313
SOLUTION_FILE: GraphRag.slnx
1414

1515
jobs:

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
workflow_dispatch:
77

88
env:
9-
DOTNET_VERSION: '9.0.x'
9+
DOTNET_VERSION: '10.0.x'
1010
SOLUTION_FILE: GraphRag.slnx
1111

1212
jobs:

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- Always run `dotnet format GraphRag.slnx` before finishing work.
1010
- Always run `dotnet test GraphRag.slnx` before finishing work, after building.
1111
- Avoid per-client connection locks (e.g., `_connectionLock` in `AgeClient`); rely on the smart connection manager for concurrency.
12+
- When initialization logic is required (initialization tasks), add a simple hosted service to perform it and register that hosted service inside the relevant extensions.
1213

1314
# Conversations
1415
any resulting updates to agents.md should go under the section "## Rules to follow"

Directory.Build.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
<RepositoryUrl>https://github.com/managedcode/graphrag</RepositoryUrl>
2626
<PackageProjectUrl>https://github.com/managedcode/graphrag</PackageProjectUrl>
2727
<Product>Managed Code GraphRag</Product>
28-
<Version>0.0.5</Version>
29-
<PackageVersion>0.0.5</PackageVersion>
28+
<Version>0.0.6</Version>
29+
<PackageVersion>0.0.6</PackageVersion>
3030

3131
</PropertyGroup>
3232
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

Directory.Packages.props

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Project>
22
<ItemGroup>
33
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
4-
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.54.0" />
5-
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="9.0.10" />
6-
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="9.0.10" />
7-
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="9.0.10" />
8-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="9.0.10" />
9-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.10" />
10-
<PackageVersion Include="Microsoft.Extensions.AI" Version="9.10.1" />
11-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="9.10.1" />
12-
<PackageVersion Include="Microsoft.Extensions.Options" Version="9.0.10" />
13-
<PackageVersion Include="Microsoft.ML.Tokenizers" Version="1.0.2" />
14-
<PackageVersion Include="Microsoft.ML.Tokenizers.Data.O200kBase" Version="1.0.2" />
15-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.0" />
4+
<PackageVersion Include="Microsoft.Azure.Cosmos" Version="3.54.1" />
5+
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.0" />
6+
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="10.0.0" />
7+
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
8+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.0" />
9+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.0" />
10+
<PackageVersion Include="Microsoft.Extensions.AI" Version="10.0.0" />
11+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="10.0.0" />
12+
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.0" />
13+
<PackageVersion Include="Microsoft.ML.Tokenizers" Version="2.0.0" />
14+
<PackageVersion Include="Microsoft.ML.Tokenizers.Data.O200kBase" Version="2.0.0" />
15+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
1616
<PackageVersion Include="Neo4j.Driver" Version="5.28.3" />
1717
<PackageVersion Include="Npgsql" Version="9.0.4" />
1818
<PackageVersion Include="DotNet.ReproducibleBuilds" Version="1.2.39" />
@@ -21,4 +21,4 @@
2121
<PackageVersion Include="xunit" Version="2.9.3" />
2222
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
2323
</ItemGroup>
24-
</Project>
24+
</Project>

src/ManagedCode.GraphRag.Postgres/ApacheAge/AgeConnectionManager.cs

Lines changed: 18 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ public sealed class AgeConnectionManager : IAgeConnectionManager
1515
{
1616
private readonly NpgsqlDataSource _dataSource;
1717
private readonly ILogger<AgeConnectionManager> _logger;
18-
private readonly SemaphoreSlim _extensionLock = new(1, 1);
19-
private readonly SemaphoreSlim _poolSemaphore;
20-
private bool _extensionEnsured;
18+
private volatile bool _extensionEnsured;
2119
private bool _disposed;
2220

2321
public AgeConnectionManager(string connectionString, ILogger<AgeConnectionManager>? logger = null, int maxPoolSize = 100)
@@ -35,7 +33,6 @@ public AgeConnectionManager(string connectionString, ILogger<AgeConnectionManage
3533
};
3634

3735
ConnectionString = connectionBuilder.ConnectionString;
38-
_poolSemaphore = new SemaphoreSlim(maxPoolSize, maxPoolSize);
3936
_dataSource = NpgsqlDataSource.Create(connectionBuilder.ConnectionString);
4037
_logger = logger ?? NullLogger<AgeConnectionManager>.Instance;
4138
}
@@ -46,43 +43,28 @@ public async Task<NpgsqlConnection> OpenConnectionAsync(CancellationToken cancel
4643
{
4744
ThrowIfDisposed();
4845

49-
await _poolSemaphore.WaitAsync(cancellationToken).ConfigureAwait(false);
50-
try
51-
{
52-
await EnsureExtensionCreatedAsync(cancellationToken).ConfigureAwait(false);
53-
var connection = await _dataSource.OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
54-
await LoadAgeAsync(connection, cancellationToken).ConfigureAwait(false);
55-
await SetSearchPathAsync(connection, cancellationToken).ConfigureAwait(false);
56-
return connection;
57-
}
58-
catch
59-
{
60-
_poolSemaphore.Release();
61-
throw;
62-
}
46+
await EnsureExtensionCreatedAsync(cancellationToken).ConfigureAwait(false);
47+
var connection = await _dataSource.OpenConnectionAsync(cancellationToken).ConfigureAwait(false);
48+
await LoadAgeAsync(connection, cancellationToken).ConfigureAwait(false);
49+
await SetSearchPathAsync(connection, cancellationToken).ConfigureAwait(false);
50+
return connection;
6351
}
6452

6553
public async Task ReturnConnectionAsync(NpgsqlConnection connection, CancellationToken cancellationToken = default)
6654
{
6755
if (connection is null)
6856
{
69-
_poolSemaphore.Release();
7057
return;
7158
}
7259

73-
try
74-
{
75-
if (connection.FullState.HasFlag(System.Data.ConnectionState.Open))
76-
{
77-
await connection.CloseAsync().ConfigureAwait(false);
78-
}
60+
cancellationToken.ThrowIfCancellationRequested();
7961

80-
await connection.DisposeAsync().ConfigureAwait(false);
81-
}
82-
finally
62+
if (connection.FullState.HasFlag(System.Data.ConnectionState.Open))
8363
{
84-
_poolSemaphore.Release();
64+
await connection.CloseAsync().ConfigureAwait(false);
8565
}
66+
67+
await connection.DisposeAsync().ConfigureAwait(false);
8668
}
8769

8870
public void Dispose()
@@ -93,7 +75,6 @@ public void Dispose()
9375
}
9476

9577
_dataSource.Dispose();
96-
_poolSemaphore.Dispose();
9778
_disposed = true;
9879
GC.SuppressFinalize(this);
9980
}
@@ -106,7 +87,6 @@ public async ValueTask DisposeAsync()
10687
}
10788

10889
await _dataSource.DisposeAsync().ConfigureAwait(false);
109-
_poolSemaphore.Dispose();
11090
_disposed = true;
11191
GC.SuppressFinalize(this);
11292
}
@@ -118,26 +98,13 @@ private async Task EnsureExtensionCreatedAsync(CancellationToken cancellationTok
11898
return;
11999
}
120100

121-
await _extensionLock.WaitAsync(cancellationToken).ConfigureAwait(false);
122-
try
123-
{
124-
if (_extensionEnsured)
125-
{
126-
return;
127-
}
128-
129-
await using var connection = new NpgsqlConnection(ConnectionString);
130-
await connection.OpenAsync(cancellationToken).ConfigureAwait(false);
131-
await using var command = connection.CreateCommand();
132-
command.CommandText = "CREATE EXTENSION IF NOT EXISTS age;";
133-
await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
134-
_extensionEnsured = true;
135-
LogMessages.ExtensionCreated(_logger, ConnectionString);
136-
}
137-
finally
138-
{
139-
_extensionLock.Release();
140-
}
101+
await using var connection = new NpgsqlConnection(ConnectionString);
102+
await connection.OpenAsync(cancellationToken).ConfigureAwait(false);
103+
await using var command = connection.CreateCommand();
104+
command.CommandText = "CREATE EXTENSION IF NOT EXISTS age;";
105+
await command.ExecuteNonQueryAsync(cancellationToken).ConfigureAwait(false);
106+
_extensionEnsured = true;
107+
LogMessages.ExtensionCreated(_logger, ConnectionString);
141108
}
142109

143110
private async Task LoadAgeAsync(NpgsqlConnection connection, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)