From 2b6826ebc3f7c40d3136349f8b814017ec407a78 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:19:47 +0000 Subject: [PATCH 1/5] Initial plan From 699fcd8455aa9993653a204b98bd9eea1d6108eb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:22:33 +0000 Subject: [PATCH 2/5] Fix empty catch blocks in transaction rollback handlers Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com> --- src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs index e3c9a64..22286ff 100644 --- a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs +++ b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs @@ -870,13 +870,13 @@ 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.LogWarning(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; } @@ -1023,7 +1023,7 @@ 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.LogWarning(rollbackEx, "Failed to rollback transaction after database corruption"); } throw new CorruptDatabaseException("SQLite database is corrupt", ex); } catch (Exception ex) From 4e3448db5df3daf1f5a9d93d97de3a6d4306d5b8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:23:23 +0000 Subject: [PATCH 3/5] Add missing transaction rollback in PruneOplogAsync exception handler Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com> --- src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs index 22286ff..5de4726 100644 --- a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs +++ b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs @@ -1029,6 +1029,7 @@ DELETE FROM Oplog catch (Exception ex) { _logger.LogError(ex, "Failed to prune oplog"); + try { transaction.Rollback(); } catch (Exception rollbackEx) { _logger.LogWarning(rollbackEx, "Failed to rollback transaction"); } throw; } } From 0dc50cb4c11d26bbf95a6b78983381d684282dc5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:24:08 +0000 Subject: [PATCH 4/5] Use LogError for rollback failures in database corruption cases Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com> --- src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs index 5de4726..a7b0962 100644 --- a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs +++ b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs @@ -870,7 +870,7 @@ 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 (Exception rollbackEx) { _logger.LogWarning(rollbackEx, "Failed to rollback transaction after database corruption"); } + 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) @@ -1023,7 +1023,7 @@ 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 (Exception rollbackEx) { _logger.LogWarning(rollbackEx, "Failed to rollback transaction after database corruption"); } + 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) From 7aa790cfa12975396834bc7eb59b7d6810ceab0b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 26 Jan 2026 19:24:56 +0000 Subject: [PATCH 5/5] Format try-catch blocks with multi-line style for better readability Co-authored-by: mrdevrobot <12503462+mrdevrobot@users.noreply.github.com> --- .../SqlitePeerStore.cs | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs index a7b0962..695052d 100644 --- a/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs +++ b/src/EntglDb.Persistence.Sqlite/SqlitePeerStore.cs @@ -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 (Exception rollbackEx) { _logger.LogError(rollbackEx, "Failed to rollback transaction after database corruption"); } + 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 (Exception rollbackEx) { _logger.LogWarning(rollbackEx, "Failed to rollback transaction"); } + try + { + transaction.Rollback(); + } + catch (Exception rollbackEx) + { + _logger.LogWarning(rollbackEx, "Failed to rollback transaction"); + } throw; } @@ -1023,13 +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 (Exception rollbackEx) { _logger.LogError(rollbackEx, "Failed to rollback transaction after database corruption"); } + 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"); } + try + { + transaction.Rollback(); + } + catch (Exception rollbackEx) + { + _logger.LogWarning(rollbackEx, "Failed to rollback transaction"); + } throw; } }