Обратите внимание, что я запускаю приложение службы Windows, используя .NET Framework 4.6.2
, и только иногда возникает эта ошибка:
2019-04-22 18:35:36.7727|ERROR|DataIntegrator.MyService|ERROR: code = IoErr (10), message = System.Data.SQLite.SQLiteException (0x800007FF): disk I/O error
disk I/O error
at System.Data.SQLite.SQLite3.Prepare(SQLiteConnection cnn, String strSql, SQLiteStatement previous, UInt32 timeoutMS, String& strRemain)
at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
at System.Data.SQLite.SQLiteDataReader.NextResult()
at System.Data.SQLite.SQLiteDataReader..ctor(SQLiteCommand cmd, CommandBehavior behave)
at System.Data.SQLite.SQLiteCommand.ExecuteReader(CommandBehavior behavior)
at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(CommandBehavior behavior)
at System.Data.SQLite.SQLiteHelper.Insert(String tableName, Dictionary`2 dic) in C:\Projects\DataIntegrator\DataIntegrator\DataAccessLayer\SQLiteHelper.cs:line 254
at System.Data.SQLite.Insert.InsertTag(Tag tag) in C:\Projects\DataIntegrator\DataIntegrator\DataAccessLayer\Query\Insert.cs:line 60
Вот мой код с ошибкой, возникающей в строке sh.Insert:
public static void InsertTag(Tag tag)
{
try
{
using (SQLiteConnection conn = new SQLiteConnection(Constants.DataSource))
{
using (SQLiteCommand cmd = new SQLiteCommand())
{
cmd.Connection = conn;
conn.Open();
SQLiteHelper sh = new SQLiteHelper(cmd);
var dic = new Dictionary<string, object>();
dic["Id"] = tag.Id;
dic["Item"] = tag.Item;
dic["Value"] = tag.Value;
dic["Source"] = tag.Source;
sh.Insert(Constants.TagTable, dic);
conn.Close();
}
}
}
catch (Exception ex)
{
LogError("ERROR: {0}", ex.ToString());
}
}
У кого-нибудь есть предложения? Вот некоторые другие ссылки, которые я проверил, но еще не нашел решения:
SQLiteDiskIOException с кодом ошибки 10: ошибка дискового ввода-вывода
ошибка дискового ввода-вывода sqlite3 на cli
https://dba.stackexchange.com/questions/93575/sqlite-disk-io-error-3850
https://github.com/linuxserver/docker-sonarr/issues/38
https://forums.sonarr.tv/t/disk-io-and-sqllite-error/5578
В последнем упоминается, что база данных повреждена, но когда я останавливаю консольное приложение, я могу открыть базу данных. Должен ли я использовать другую базу данных, такую как Berkeley DB, которая потенциально имеет более высокую производительность?
https://www.oracle.com/technetwork/database/database-technologies/berkeleydb/downloads/index.html
ОБНОВЛЕНИЕ:
Добавлены ОС в теги
SQLiteHelper.cs:line 254
, а неInsertTag
.InsertTag
(Insert.cs:line 60
) - это место, где вызываетсяSQLiteHelper
. - person Olivier Jacot-Descombes   schedule 23.04.2019