The tracking compensated for isManagedByCurrentService reporting isolated tenants
of a profile without dedicated servers as not managed (a dedicated server for any
other profile flipped it). That root cause is fixed in #16345, after which a
tenant's managed status changes only together with its own queue ownership, and
its queue keys are already in the partition change event.
Replace the test that pinned the old flip with one that checks the affected
tenants when a dedicated server for the tenant's own profile joins and leaves.
WhiteLabelingControllerTest saves the system-level login white-labeling
params with baseUrl "https://domain.com" and never restores them. The
params persist in the shared test database, so when QrCodeSettingsControllerTest
runs later in the same JVM, getBaseUrl() resolves the system base URL to
domain.com and testGetMobileDeepLink fails with
expected "localhost" but was "domain.com".
Reset system white-labeling settings after every WhiteLabelingControllerTest
test, and reset them in QrCodeSettingsControllerTest setup as well.
/api/agentInfos?agentIds=... is served by a derived JPA 'id IN (...)'
query with no ORDER BY, so PostgreSQL may return rows in any order
(e.g. physical tuple order after an UPDATE). The test asserted
infos.get(0) == first and infos.get(1) == second, and failed whenever
the rows came back reversed. Match the returned infos by id instead.
After the managed-status fix the field was only written, never read. It
also held the fallback entries added by resolveByPartitionIdx, so reading
it later as "profiles with dedicated servers" would bring the bug back.
HashPartitionService.resolveByPartitionIdx caches the fallback (regular)
servers of an isolated profile without dedicated servers in
responsibleServices. isManagedByCurrentService then saw a non-empty list
for that profile and reported its tenants as not managed on the regular
servers, although those servers own the tenants' partitions. This happens
as soon as any dedicated server exists in the cluster.
Remember which profiles have dedicated servers before the fallback entries
are added, and use that set in isManagedByCurrentService.
- Resolve affected tenants in PartitionChangeEvent.getAffectedTenants(),
returning null (all tenants) for non rule engine events, empty diffs and
shared queue changes.
- HashPartitionService adds isolated tenants whose managed status changed
without a change of their own queue keys.
- PartitionChangeMsg: forAllTenants/forTenants factories instead of a null
sentinel; affected tenants excluded from toString().
- Fold the AppActor log line into the existing DefaultActorService one.
- Tests: priority ordering in ActorSystemTest, AppActorTest on a real actor
system, DefaultActorServiceTest through onTbApplicationEvent, the
managed-status scenario in HashPartitionServiceTest.
AppActor.doProcess unconditionally broadcasts PARTITION_CHANGE_MSG to
every live TenantActor at high priority, regardless of whether a given
tenant's ownership actually changed. On a shared rule-engine instance
hosting many tenants, this means any single tenant's partition change
(e.g. moving to an isolated queue) interrupts every other tenant's
in-flight message processing, even though only one tenant's ownership
changed.
DefaultActorService now resolves which tenants are actually affected
from the partition-change diff it already has on hand (returning null
when the shared/non-isolated pool itself changed, since those tenants
aren't individually tracked and everyone must still be notified), and
AppActor uses that to broadcast only to the affected tenant actors,
reusing the existing TbEntityTypeActorIdPredicate filtering idiom.
Falls back to the original broadcast-to-everyone behavior whenever the
affected set can't be narrowed down.
PartitionChangeMsg only carried the affected ServiceType, so a
consumer had no way to know which specific tenants (if any) a given
partition change actually affects versus all of them. Add an optional
affectedTenants set: null preserves today's meaning ("could affect
anyone, notify everyone"), a non-null set means only those tenants are
affected. Existing single-arg construction is unchanged and keeps
defaulting to null.
TbActorSystem/TbActorCtx already supported broadcasting to a filtered
subset of children, and separately broadcasting to all children at a
given priority, but not both together. Expose the existing internal
implementation (already used for the priority-only case) as a public
filtered + prioritized overload, so callers can target a subset of
children without giving up delivery priority.
Calculated field actors page through each tenant's calculated fields on
startup (WHERE tenant_id = ? ORDER BY id LIMIT ?). With no index leading on
tenant_id, every page and its count query scan the whole table and sort,
so startup cost grows with tenants x table size.
Ship the index in schema-entities-idx.sql for new installs and as a new
4.4.1.0 LTS migration for existing ones (4.4.0.0 is already released, and
the range lower bound is exclusive).