Skip to content

Commit 4d00a31

Browse files
committed
Correct connector type mapper reseting logic
Which led to a serious memory leak. Fixes npgsql#2234
1 parent 17f6fa6 commit 4d00a31

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Npgsql/NpgsqlConnection.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,10 @@ Task Open(bool async, CancellationToken cancellationToken)
237237
var mapper = Connector.TypeMapper;
238238
if (mapper.ChangeCounter != TypeMapping.GlobalTypeMapper.Instance.ChangeCounter)
239239
{
240-
// We always do this synchronously which isn't amazing but not very important
240+
// We always do this synchronously which isn't amazing but not very important, because
241+
// it's supposed to be a pretty rare event and the whole point is to keep this method
242+
// non-async
241243
Connector.LoadDatabaseInfo(NpgsqlTimeout.Infinite, false).GetAwaiter().GetResult();
242-
mapper.Reset();
243244
}
244245

245246
Debug.Assert(Connector.Connection != null, "Open done but connector not set on Connection");
@@ -307,10 +308,7 @@ async Task OpenLong()
307308
// or global mappings may have changed. Bring this up to date if needed.
308309
mapper = Connector.TypeMapper;
309310
if (mapper.ChangeCounter != TypeMapping.GlobalTypeMapper.Instance.ChangeCounter)
310-
{
311311
await Connector.LoadDatabaseInfo(NpgsqlTimeout.Infinite, async);
312-
mapper.Reset();
313-
}
314312
}
315313

316314
// We may have gotten an already enlisted pending connector above, no need to enlist in that case

0 commit comments

Comments
 (0)