Skip to content

Commit

Permalink
Expose number of FINISHING queries
Browse files Browse the repository at this point in the history
Sometimes a query may spend a sifnificant amount of time in FINISHING
state if query result is large and all tasks already finished execution.
This is possible with fault tolerant execution.
  • Loading branch information
losipiuk committed Oct 7, 2024
1 parent 7ec87bc commit a803861
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static io.airlift.concurrent.Threads.daemonThreadsNamed;
import static io.trino.execution.QueryState.FINISHING;
import static io.trino.execution.QueryState.QUEUED;
import static io.trino.execution.QueryState.RUNNING;
import static io.trino.spi.StandardErrorCode.QUERY_TEXT_TOO_LARGE;
Expand Down Expand Up @@ -330,6 +331,14 @@ public long getRunningQueries()
.count();
}

@Managed
public long getFinishingQueries()
{
return queryTracker.getAllQueries().stream()
.filter(query -> query.getState() == FINISHING)
.count();
}

@Managed
public long getProgressingQueries()
{
Expand Down

0 comments on commit a803861

Please sign in to comment.