Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 32 additions & 3 deletions src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -870,13 +870,27 @@ INSERT INTO Oplog (Collection, Key, Operation, JsonData, HlcWall, HlcLogic, HlcN
catch (SqliteException ex) when (ex.SqliteErrorCode == 11 || ex.SqliteErrorCode == 26) // SQLITE_CORRUPT or SQLITE_NOTADB
{
_logger.LogCritical(ex, "Database corruption detected during ApplyBatchAsync!");
try { transaction.Rollback(); } catch { }
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
_logger.LogError(rollbackEx, "Failed to rollback transaction after database corruption");
}
throw new CorruptDatabaseException("SQLite database is corrupt", ex);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to apply batch");
try { transaction.Rollback(); } catch { }
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
_logger.LogWarning(rollbackEx, "Failed to rollback transaction");
}
throw;
}

Expand Down Expand Up @@ -1023,12 +1037,27 @@ DELETE FROM Oplog
catch (SqliteException ex) when (ex.SqliteErrorCode == 11 || ex.SqliteErrorCode == 26) // SQLITE_CORRUPT or SQLITE_NOTADB
{
_logger.LogCritical(ex, "Database corruption detected during oplog pruning (PruneOplogAsync).");
try { transaction.Rollback(); } catch { }
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
_logger.LogError(rollbackEx, "Failed to rollback transaction after database corruption");
}
throw new CorruptDatabaseException("SQLite database is corrupt", ex);
}
catch (Exception ex)
{
_logger.LogError(ex, "Failed to prune oplog");
try
{
transaction.Rollback();
}
catch (Exception rollbackEx)
{
_logger.LogWarning(rollbackEx, "Failed to rollback transaction");
}
throw;
}
}
Expand Down
Loading