Skip to content

Commit b900eaf

Browse files
authored
Merge pull request #454 from DataObjects-NET/7.2-no-exception-overwrite-on-commit-upgrade
No exception overwriting when it happens on upgrade transaction commit
2 parents 2d33dea + b789283 commit b900eaf

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

ChangeLog/7.2.1-dev.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
[main] Added Query.SingleAsync()/SingleOrDefaultAsync and QueryEndpoint.SingleAsync()/SingleOrDefaultAsync methods
22
[main] Addressed issue of not disposing IAsyncEnumerator which caused query being open
3+
[main] Addressed issue of overwriting exception on attempt to rollback the transaction of Domain upgrade if commit operation failed
4+
[postgresql] Update Npgsql to 9.0.4

Orm/Xtensive.Orm/Orm/Upgrade/UpgradingDomainBuilder.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,13 @@ private void CompleteUpgradeTransaction()
172172
driver.CommitTransaction(null, connection);
173173
}
174174
catch {
175-
driver.RollbackTransaction(null, connection);
175+
// If transaction has become broken during commit its rollback leads to new exception
176+
// which will overwrite the original one.
177+
// Check for active transaction should work because on exception within
178+
// driver.Commit it is set to NULL.
179+
if (connection.ActiveTransaction != null) {
180+
driver.RollbackTransaction(null, connection);
181+
}
176182
throw;
177183
}
178184
}
@@ -190,7 +196,13 @@ private async ValueTask CompleteUpgradeTransactionAsync(CancellationToken token)
190196
await driver.CommitTransactionAsync(null, connection, token);
191197
}
192198
catch {
193-
await driver.RollbackTransactionAsync(null, connection, token);
199+
// If transaction has become broken during commit its rollback leads to new exception
200+
// which will overwrite the original one.
201+
// Check for active transaction should work because on exception within
202+
// driver.Commit it is set to NULL.
203+
if (connection.ActiveTransaction != null) {
204+
await driver.RollbackTransactionAsync(null, connection, token);
205+
}
194206
throw;
195207
}
196208
}

0 commit comments

Comments
 (0)