This is an automated email from the ASF dual-hosted git repository.
zstan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new fe470de1472 IGNITE-17195 Trigger failure handler if h2 database is
down - Fixes #10131.
fe470de1472 is described below
commit fe470de14729dcca2c7ed956932f7828f7c73ff0
Author: zstan <[email protected]>
AuthorDate: Thu Jul 7 08:09:06 2022 +0300
IGNITE-17195 Trigger failure handler if h2 database is down - Fixes #10131.
Signed-off-by: zstan <[email protected]>
---
.../processors/cache/query/IgniteQueryErrorCode.java | 3 +++
.../internal/processors/query/h2/IgniteH2Indexing.java | 11 ++++-------
.../ignite/internal/processors/query/h2/QueryParser.java | 15 ++++++++++++++-
3 files changed, 21 insertions(+), 8 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
index 9a98419498a..00fdf55166d 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/query/IgniteQueryErrorCode.java
@@ -86,6 +86,9 @@ public final class IgniteQueryErrorCode {
/** Required schema not found. */
public static final int SCHEMA_NOT_FOUND = 3015;
+ /** Database is closed by some reasons. */
+ public static final int DB_UNRECOVERABLE_ERROR = 3016;
+
/* 4xxx - cache related runtime errors */
/** Attempt to INSERT a key that is already in cache. */
diff --git
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
index 0d0b935807c..de50cf23ed8 100644
---
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
+++
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/IgniteH2Indexing.java
@@ -524,7 +524,6 @@ public class IgniteH2Indexing implements GridQueryIndexing {
* @param inTx Flag whether the query is executed in transaction.
* @param timeout Timeout.
* @return Query result.
- * @throws IgniteCheckedException If failed.
*/
private GridQueryFieldsResult executeSelectLocal(
long qryId,
@@ -536,7 +535,7 @@ public class IgniteH2Indexing implements GridQueryIndexing {
GridQueryCancel cancel,
boolean inTx,
int timeout
- ) throws IgniteCheckedException {
+ ) {
assert !select.mvccEnabled() || mvccTracker != null;
String qry;
@@ -1397,7 +1396,6 @@ public class IgniteH2Indexing implements
GridQueryIndexing {
* @param cancel Cancel.
* @param timeout Timeout.
* @return Fields query.
- * @throws IgniteCheckedException On error.
*/
private QueryCursorImpl<List<?>> executeSelectForDml(
long qryId,
@@ -1406,7 +1404,7 @@ public class IgniteH2Indexing implements
GridQueryIndexing {
MvccQueryTracker mvccTracker,
GridQueryCancel cancel,
int timeout
- ) throws IgniteCheckedException {
+ ) {
QueryParserResult parseRes = parser.parse(schema, selectQry, false);
QueryParserResultSelect select = parseRes.select();
@@ -1447,7 +1445,6 @@ public class IgniteH2Indexing implements
GridQueryIndexing {
* @param inTx Flag whether query is executed within transaction.
* @param timeout Timeout.
* @return Query result.
- * @throws IgniteCheckedException On error.
*/
private Iterable<List<?>> executeSelect0(
long qryId,
@@ -1459,7 +1456,7 @@ public class IgniteH2Indexing implements
GridQueryIndexing {
GridQueryCancel cancel,
boolean inTx,
int timeout
- ) throws IgniteCheckedException {
+ ) {
assert !select.mvccEnabled() || mvccTracker != null;
// Check security.
@@ -1664,7 +1661,7 @@ public class IgniteH2Indexing implements
GridQueryIndexing {
AffinityTopologyVersion topVer,
MvccSnapshot mvccSnapshot,
GridQueryCancel cancel
- ) throws IgniteCheckedException {
+ ) {
SqlFieldsQuery fldsQry = QueryUtils.withQueryTimeout(new
SqlFieldsQuery(qry), timeout, TimeUnit.MILLISECONDS);
if (params != null)
diff --git
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
index be522466e38..4b2948808ec 100644
---
a/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
+++
b/modules/indexing/src/main/java/org/apache/ignite/internal/processors/query/h2/QueryParser.java
@@ -30,6 +30,7 @@ import org.apache.ignite.IgniteLogger;
import org.apache.ignite.IgniteSystemProperties;
import org.apache.ignite.cache.CacheAtomicityMode;
import org.apache.ignite.cache.query.SqlFieldsQuery;
+import org.apache.ignite.failure.FailureContext;
import org.apache.ignite.internal.processors.cache.GridCacheContext;
import org.apache.ignite.internal.processors.cache.GridCacheContextInfo;
import org.apache.ignite.internal.processors.cache.mvcc.MvccUtils;
@@ -64,9 +65,11 @@ import org.apache.ignite.internal.sql.command.SqlCommand;
import org.apache.ignite.internal.util.GridBoundedConcurrentLinkedHashMap;
import org.apache.ignite.internal.util.typedef.F;
import org.apache.ignite.internal.util.typedef.internal.U;
+import org.h2.api.ErrorCode;
import org.h2.command.Prepared;
import org.jetbrains.annotations.Nullable;
+import static org.apache.ignite.failure.FailureType.CRITICAL_ERROR;
import static
org.apache.ignite.internal.processors.query.h2.sql.GridSqlQuerySplitter.keyColumn;
import static
org.apache.ignite.internal.processors.tracing.SpanTags.SQL_PARSER_CACHE_HIT;
import static
org.apache.ignite.internal.processors.tracing.SpanType.SQL_QRY_PARSE;
@@ -585,7 +588,17 @@ public class QueryParser {
null
);
}
- catch (IgniteCheckedException | SQLException e) {
+ catch (SQLException e) {
+ if (e.getErrorCode() == ErrorCode.DATABASE_IS_CLOSED) {
+ idx.kernalContext().failure().process(new
FailureContext(CRITICAL_ERROR, e));
+
+ throw new IgniteSQLException("Critical database error. " +
e.getMessage(),
+ IgniteQueryErrorCode.DB_UNRECOVERABLE_ERROR, e);
+ }
+ else
+ throw new IgniteSQLException("Failed to parse query. " +
e.getMessage(), IgniteQueryErrorCode.PARSING, e);
+ }
+ catch (IgniteCheckedException e) {
throw new IgniteSQLException("Failed to parse query. " +
e.getMessage(), IgniteQueryErrorCode.PARSING, e);
}
finally {