Let onError always succeed on cluster version changes (#8841)

This commit is contained in:
Vaidas Gasiunas 2022-11-21 20:31:32 +01:00 committed by GitHub
parent c8937d2ae9
commit 084a78fded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 9 deletions

View File

@ -1548,17 +1548,19 @@ ThreadFuture<Void> MultiVersionTransaction::onError(Error const& e) {
auto f = tr.transaction ? tr.transaction->onError(e) : makeTimeout<Void>();
f = abortableFuture(f, tr.onChange);
return flatMapThreadFuture<Void, Void>(f, [this, e](ErrorOr<Void> ready) {
if (!ready.isError() || ready.getError().code() != error_code_cluster_version_changed) {
if (ready.isError()) {
return ErrorOr<ThreadFuture<Void>>(ready.getError());
}
return flatMapThreadFuture<Void, Void>(f, [this](ErrorOr<Void> ready) {
if (ready.isError() && ready.getError().code() == error_code_cluster_version_changed) {
// In case of a cluster version change, upgrade (or downgrade) the transaction
// and let it to be retried independently of the original error
updateTransaction();
return ErrorOr<ThreadFuture<Void>>(Void());
}
// In all other cases forward the result of the inner onError call
if (ready.isError()) {
return ErrorOr<ThreadFuture<Void>>(ready.getError());
} else {
return ErrorOr<ThreadFuture<Void>>(Void());
}
updateTransaction();
return ErrorOr<ThreadFuture<Void>>(onError(e));
});
}
}