sanpwc commented on code in PR #2186: URL: https://github.com/apache/ignite-3/pull/2186#discussion_r1238933373
########## modules/api/src/main/java/org/apache/ignite/lang/RecoverableException.java: ########## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.lang; + +/** + * This is a marker interface to indicate a recoverable error. + * When an exception marked by {@link RecoverableException} is thrown, it means that an operation failed for some reason, + * but this failure is not fatal and the operation can be retried. + * + * <code> + * try { + * Transaction tx = ignite.transactions().begin(); + * ... + * tx.commit(); + * } catch (TransactionException t) { + * if (t instanceof RecoverableException) { + * // put your retry logic here. + * } + * } + * </code> + */ +public interface RecoverableException { Review Comment: To be honest I'm not sure whether proposed approach with RecoverableException interface is good enough. In many cases recoverability is context-depended. - It's possible to retry tx request after lock exception if nothing was shared with a user, so formally LockExpcetion is RecoverableException, however in real life it is "sometimes recoverable". - Same is about PrimaryReplicaMissException. If there wasn't any successful touches of given partition it's possible to retry the invoke, otherwise it's not. All in all, RecoverableException might bring even more mess. ########## modules/api/src/main/java/org/apache/ignite/lang/RecoverableException.java: ########## @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.ignite.lang; + +/** + * This is a marker interface to indicate a recoverable error. + * When an exception marked by {@link RecoverableException} is thrown, it means that an operation failed for some reason, + * but this failure is not fatal and the operation can be retried. + * + * <code> + * try { + * Transaction tx = ignite.transactions().begin(); + * ... + * tx.commit(); + * } catch (TransactionException t) { + * if (t instanceof RecoverableException) { + * // put your retry logic here. + * } + * } + * </code> + */ +public interface RecoverableException { Review Comment: To be honest I'm not sure whether proposed approach with RecoverableException interface is good enough. In many cases recoverability is context-depended. - It's possible to retry tx request after lock exception if nothing was shared with a user, so formally LockExpcetion is RecoverableException, however in real life it is "sometimes recoverable". - Same is about PrimaryReplicaMissException. If there wasn't any successful touches of given partition it's possible to retry the invoke, otherwise it's not. All in all, RecoverableException might bring even more mess. -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org