Skip to content

bpm: a process-instance listing resolves every activity in three queries - #7266

Open
delchev wants to merge 1 commit into
masterfrom
issue-7250-bpm-instance-activity-batch
Open

bpm: a process-instance listing resolves every activity in three queries#7266
delchev wants to merge 1 commit into
masterfrom
issue-7250-bpm-instance-activity-batch

Conversation

@delchev

@delchev delchev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What

BpmService.getProcessInstances resolved each instance's activity id one instance at a time - getActiveActivityIds, a JobQuery and a TimerJobQuery, three statements apiece (#7212). GET /services/bpm/bpm-processes/instances is unbounded, and the Monitoring shell's Overview polls it with no key every 30 s, so a tenant with a few hundred running instances paid 3N statements per poll.

The resolution now happens for the whole listing at once, in BpmProviderFlowable.getProcessInstanceActivityIds(List<ProcessInstance>):

  • one ExecutionQuery over all the listed ids (processInstanceIds + onlyChildExecutions, tenant-scoped), filtered to the active executions - the flag is not a query criterion, so it is read off the returned rows, which keeps a scope execution (a subprocess or multi-instance parent) from being reported as a second activity;
  • the two job queries over the current tenant - Flowable's job queries take a single process-instance id, so the tenant is the narrowest batch filter available - matched against the listed ids in memory.

The evidence and the answer are unchanged, including a step parked between retry attempts that only its own timer job names (#7193). The single-instance path (/instance/{id}, the diagram) keeps its targeted queries.

Tests

BpmProviderFlowableActiveActivitiesTest, against a real in-memory engine:

  • the batch answers a parked step, an untried async step and a wait state in one call;
  • an instance outside the listing is never answered for, though the job queries read the whole tenant;
  • an empty listing asks the engine nothing;
  • the query count does not grow with the listing - 2 instances and 8 instances both cost exactly 3 queries, read back from H2's INFORMATION_SCHEMA.QUERY_STATISTICS. That is the regression this fix is about.

mvn -pl components/engine/engine-bpm-flowable test - 35/35 green.

Note

The nit from the issue is fixed too: both in-memory engine tests meant DB_CLOSE_DELAY=-1, not 1000.

While here: the limit: 100 the AngularJS Processes view sends is not a parameter the endpoint declares, so it is dropped on the floor - capping the call would not have helped, which is why this batches instead.

Fixes #7250

🤖 Generated with Claude Code

#7212 made the listing resolve each instance's activity id instead of
reading the always-null one off the instance, at three queries apiece -
an execution query and the two job queries. The Monitoring shell's
Overview polls the listing with no key and no limit every 30 s, so a
tenant with a few hundred running instances paid 3N statements a poll
for a column the listing renders as one badge.

The resolution is now done for the whole listing at once: one execution
query over all the listed ids, and the two job queries over the current
tenant - Flowable's job queries take a single process-instance id, so
the tenant is the narrowest batch filter there is - grouped by process
instance in memory. The evidence and the answer are unchanged, down to a
step parked between retry attempts that only its own timer job still
names; the query count no longer grows with the listing, which the new
engine test pins by reading H2's own query statistics.

The single-instance path keeps its targeted queries.

Also: the two in-memory engine tests meant DB_CLOSE_DELAY=-1, not 1000.

Fixes #7250

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bpm: the process-instance listing now runs three queries per instance to resolve its activity - the Monitoring Overview polls it unbounded every 30 s

1 participant