[ 
https://issues.apache.org/jira/browse/IGNITE-19895?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Evgeny Stanilovsky updated IGNITE-19895:
----------------------------------------
    Description: 
Check code below (QueryCancel#cancel), casts checked exception into unchecked 
one thus there are exist some places without catching such exception which can 
lead to tx\resources leakage.


{code:java}
    public synchronized void cancel() {
        if (canceled) {
            return;
        }

        canceled = true;

        IgniteException ex = null;

        // Run actions in the reverse order.
        for (int i = cancelActions.size() - 1; i >= 0; i--) {
            try {
                Cancellable act = cancelActions.get(i);

                act.cancel();
            } catch (Exception e) {
                if (ex == null) {
                    ex = new SqlException(CANCEL_OPERATION_ERR, e);
                } else {
                    ex.addSuppressed(e);
                }
            }
        }

        if (ex != null) {
            throw ex;
        }
    }
{code}

and call this method from : SqlQueryProcessor#querySingle0 like

{noformat}
        stage.whenComplete((cur, ex) -> {
            if (ex instanceof CancellationException) {
                *queryCancel.cancel();*
            }

            if (ex != null && outerTx == null) {
                InternalTransaction tx0 = tx.get();
                if (tx0 != null) {
                    tx0.rollback();
                }
            }
        }
{noformat}


may stay internal tx untouched, as i can see

  was:
Check code below (QueryCancel#cancel), casts checked exception into unchecked 
one thus there are exist some places without catching such exception which can 
lead to tx\resources leakage.


{code:java}
    public synchronized void cancel() {
        if (canceled) {
            return;
        }

        canceled = true;

        IgniteException ex = null;

        // Run actions in the reverse order.
        for (int i = cancelActions.size() - 1; i >= 0; i--) {
            try {
                Cancellable act = cancelActions.get(i);

                act.cancel();
            } catch (Exception e) {
                if (ex == null) {
                    ex = new SqlException(CANCEL_OPERATION_ERR, e);
                } else {
                    ex.addSuppressed(e);
                }
            }
        }

        if (ex != null) {
            throw ex;
        }
    }
{code}

and call this method from : SqlQueryProcessor#querySingle0 like
        stage.whenComplete((cur, ex) -> {
            if (ex instanceof CancellationException) {
                *queryCancel.cancel();*
            }

            if (ex != null && outerTx == null) {
                InternalTransaction tx0 = tx.get();
                if (tx0 != null) {
                    tx0.rollback();
                }
            }
        }

may stay internal tx untouched, as i can see


> Sql. QueryCancel#cancel cheat checking exception hierarchy
> ----------------------------------------------------------
>
>                 Key: IGNITE-19895
>                 URL: https://issues.apache.org/jira/browse/IGNITE-19895
>             Project: Ignite
>          Issue Type: Improvement
>          Components: sql
>    Affects Versions: 3.0.0-beta1
>            Reporter: Evgeny Stanilovsky
>            Priority: Major
>              Labels: ignite-3
>
> Check code below (QueryCancel#cancel), casts checked exception into unchecked 
> one thus there are exist some places without catching such exception which 
> can lead to tx\resources leakage.
> {code:java}
>     public synchronized void cancel() {
>         if (canceled) {
>             return;
>         }
>         canceled = true;
>         IgniteException ex = null;
>         // Run actions in the reverse order.
>         for (int i = cancelActions.size() - 1; i >= 0; i--) {
>             try {
>                 Cancellable act = cancelActions.get(i);
>                 act.cancel();
>             } catch (Exception e) {
>                 if (ex == null) {
>                     ex = new SqlException(CANCEL_OPERATION_ERR, e);
>                 } else {
>                     ex.addSuppressed(e);
>                 }
>             }
>         }
>         if (ex != null) {
>             throw ex;
>         }
>     }
> {code}
> and call this method from : SqlQueryProcessor#querySingle0 like
> {noformat}
>         stage.whenComplete((cur, ex) -> {
>             if (ex instanceof CancellationException) {
>                 *queryCancel.cancel();*
>             }
>             if (ex != null && outerTx == null) {
>                 InternalTransaction tx0 = tx.get();
>                 if (tx0 != null) {
>                     tx0.rollback();
>                 }
>             }
>         }
> {noformat}
> may stay internal tx untouched, as i can see



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to