rpuch commented on code in PR #3448:
URL: https://github.com/apache/ignite-3/pull/3448#discussion_r1540544645
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java:
##########
@@ -374,7 +375,44 @@ private void truncateUpTo(Catalog catalog) {
private CompletableFuture<Integer>
saveUpdateAndWaitForActivation(UpdateProducer updateProducer) {
return saveUpdate(updateProducer, 0)
- .thenCompose(newVersion -> {
+ .handle((newVersion, err) -> {
+ if (err != null) {
+ Throwable error;
+ Catalog catalog;
+
+ Throwable errUnwrapped = err instanceof
CompletionException ? err.getCause() : err;
+
+ if (errUnwrapped instanceof
CatalogVersionAwareValidationException) {
+ CatalogVersionAwareValidationException err0 =
(CatalogVersionAwareValidationException) errUnwrapped;
+ catalog = catalogByVer.get(err0.version());
+ error = err0.initial();
+ } else {
+ catalog = catalogByVer.lastEntry().getValue();
+ error = err;
+ }
+
+ if (catalog.version() == 0) {
+ return failedFuture(error).thenApply(unused ->
newVersion);
+ }
+
+ HybridTimestamp tsSafeForRoReadingInPastOptimization =
+ clusterWideEnsuredActivationTsSafeForRoReads(
Review Comment:
How about extracting this expression to a method having one parameter of
type `Catalog`? It's pretty complex and it's used twice.
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java:
##########
@@ -374,7 +375,44 @@ private void truncateUpTo(Catalog catalog) {
private CompletableFuture<Integer>
saveUpdateAndWaitForActivation(UpdateProducer updateProducer) {
return saveUpdate(updateProducer, 0)
- .thenCompose(newVersion -> {
+ .handle((newVersion, err) -> {
+ if (err != null) {
+ Throwable error;
+ Catalog catalog;
+
+ Throwable errUnwrapped = err instanceof
CompletionException ? err.getCause() : err;
Review Comment:
`ExceptionUtils.unwrapCause()`?
##########
modules/catalog/src/main/java/org/apache/ignite/internal/catalog/CatalogManagerImpl.java:
##########
@@ -374,7 +375,44 @@ private void truncateUpTo(Catalog catalog) {
private CompletableFuture<Integer>
saveUpdateAndWaitForActivation(UpdateProducer updateProducer) {
return saveUpdate(updateProducer, 0)
- .thenCompose(newVersion -> {
+ .handle((newVersion, err) -> {
+ if (err != null) {
+ Throwable error;
+ Catalog catalog;
+
+ Throwable errUnwrapped = err instanceof
CompletionException ? err.getCause() : err;
+
+ if (errUnwrapped instanceof
CatalogVersionAwareValidationException) {
+ CatalogVersionAwareValidationException err0 =
(CatalogVersionAwareValidationException) errUnwrapped;
+ catalog = catalogByVer.get(err0.version());
+ error = err0.initial();
+ } else {
+ catalog = catalogByVer.lastEntry().getValue();
+ error = err;
+ }
+
+ if (catalog.version() == 0) {
+ return failedFuture(error).thenApply(unused ->
newVersion);
Review Comment:
It seems that `thenApply()` is useless here as `failedFuture()` produces a
future completed with an exception. Is this made to change the future generic
type?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]