Do not use pooling so that we do not need to clear pool

This commit is contained in:
Jack251970 2025-06-08 12:17:47 +08:00
parent c8e82cbd09
commit 2ed32b318d
2 changed files with 4 additions and 20 deletions

View file

@ -155,9 +155,6 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
return;
}
// Cache connection for pool clean
SqliteConnection connection1 = null;
try
{
// Since some bookmarks may have same favicon id, we need to record them to avoid duplicates
@ -167,7 +164,8 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
Parallel.ForEach(bookmarks, bookmark =>
{
// Use read-only connection to avoid locking issues
var connection = new SqliteConnection($"Data Source={tempDbPath};Mode=ReadOnly");
// Do not use pooling so that we do not need to clear pool: https://github.com/dotnet/efcore/issues/26580
var connection = new SqliteConnection($"Data Source={tempDbPath};Mode=ReadOnly;Pooling=false");
connection.Open();
try
@ -221,7 +219,6 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
{
// Cache connection and clear pool after all operations to avoid issue:
// ObjectDisposedException: Safe handle has been closed.
connection1 = connection;
connection.Close();
connection.Dispose();
}
@ -235,11 +232,6 @@ public abstract class ChromiumBookmarkLoader : IBookmarkLoader
// Delete temporary file
try
{
// https://github.com/dotnet/efcore/issues/26580
if (connection1 != null)
{
SqliteConnection.ClearPool(connection1);
}
File.Delete(tempDbPath);
}
catch (Exception ex)

View file

@ -142,9 +142,6 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
return;
}
// Cache connection for pool clean
SqliteConnection connection1 = null;
try
{
// Since some bookmarks may have same favicon id, we need to record them to avoid duplicates
@ -154,7 +151,8 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
Parallel.ForEach(bookmarks, bookmark =>
{
// Use read-only connection to avoid locking issues
var connection = new SqliteConnection($"Data Source={tempDbPath};Mode=ReadOnly");
// Do not use pooling so that we do not need to clear pool: https://github.com/dotnet/efcore/issues/26580
var connection = new SqliteConnection($"Data Source={tempDbPath};Mode=ReadOnly;Pooling=false");
connection.Open();
try
@ -217,7 +215,6 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
{
// Cache connection and clear pool after all operations to avoid issue:
// ObjectDisposedException: Safe handle has been closed.
connection1 = connection;
connection.Close();
connection.Dispose();
}
@ -231,11 +228,6 @@ public abstract class FirefoxBookmarkLoaderBase : IBookmarkLoader
// Delete temporary file
try
{
// https://github.com/dotnet/efcore/issues/26580
if (connection1 != null)
{
SqliteConnection.ClearPool(connection1);
}
File.Delete(tempDbPath);
}
catch (Exception ex)