You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Jun Rao (Jira)" <ji...@apache.org> on 2025/05/23 17:29:00 UTC

[jira] [Updated] (KAFKA-19325) improve forceComplete() in DelayedOperation

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

Jun Rao updated KAFKA-19325:
----------------------------
    Description: 
After [https://github.com/apache/kafka/pull/19759/files,] DelayedOperation.forceComplete() always returns true when called inside tryComplete(). Only the expiration logic checks the return value of forceComplete(). We could do the following in the expiration logic and change forceComplete() to return void and avoid using the lock there (the caller will get the lock instead).
{code:java}
        lock.lock();
        try {
            if (!isCompleted()) {
              forceComplete();
              onExpiration();
             }
        } finally {
            lock.unlock();
        }{code}

  was:
After [https://github.com/apache/kafka/pull/19759/files,] DelayedOperation.forceComplete() always returns true when called inside tryComplete(). Only the expiration logic checks the return value of forceComplete(). We could do the following in the expiration logic and change forceComplete() to return void and avoid using the lock there (the caller will get the lock instead).

        lock.lock();
        try {
            if (!isCompleted()) {
              forceComplete();
              onExpiration();
             }
        } finally {
            lock.unlock();
        }


> improve forceComplete() in DelayedOperation
> -------------------------------------------
>
>                 Key: KAFKA-19325
>                 URL: https://issues.apache.org/jira/browse/KAFKA-19325
>             Project: Kafka
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 4.1.0
>            Reporter: Jun Rao
>            Priority: Major
>
> After [https://github.com/apache/kafka/pull/19759/files,] DelayedOperation.forceComplete() always returns true when called inside tryComplete(). Only the expiration logic checks the return value of forceComplete(). We could do the following in the expiration logic and change forceComplete() to return void and avoid using the lock there (the caller will get the lock instead).
> {code:java}
>         lock.lock();
>         try {
>             if (!isCompleted()) {
>               forceComplete();
>               onExpiration();
>              }
>         } finally {
>             lock.unlock();
>         }{code}



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