Loading

[SFS]-Overlapping Service Appointments Caused by Concurrent Optimization Requests on Territories Sharing Service Resources

Дата публикации: Jul 3, 2026
Описание

Scenario:

Two ORs are triggered at the same time for two different Service Territories. The Service Resources in these territories have the following membership:

 

Service ResourceTerritory 1 (Primary)Territory 2 (Secondary)
Service Resource APrimarySecondary
Service Resource BPrimarySecondary

Both ORs start simultaneously:

Optimization RequestTarget TerritoryStart TimeCompletion TimeOverlaps Created?
OR 1Territory 101:00 AM01:14 AMNo
OR 2Territory 201:00 AM01:28 AMYes

Root Cause

The FSL optimization engine uses an optimistic concurrency model to process scheduled runs:

  1. Data Snapshot: At the start of execution, each OR captures a point-in-time snapshot of all relevant resource availability and appointment data.

  2. Isolated Execution: The optimization engine runs entirely against this frozen, isolated snapshot.

  3. Commit Phase: Upon completion, the OR commits its scheduling results to the database without re-checking whether the underlying data changed during its execution window.

When OR 1 and OR 2 launch simultaneously, they capture an identical data snapshot. The first OR to finish (OR 1) successfully commits its valid assignments. However, when the second OR (OR 2) finishes, it writes changes based on its now-stale snapshot, inadvertently overwriting OR 1's allocations and creating overlapping appointments.

# Why Match Territory Does Not Prevent This:

Administrators often expect the Match Territory work rule to isolate territory optimization. While the rule behaves correctly, it governs policy scope rather than database transactions:

 
Match Territory BehaviorDoes it prevent this issue?
Restricts OR for Territory 2 to schedule Territory 2 SAsYes (Respected correctly)
Restricts OR for Territory 1 to schedule Territory 1 SAsYes (Respected correctly)
Prevents cross-territory SA assignmentsYes (Respected correctly)
Locks shared resources from concurrent OR processingNo (Outside the scope of this rule)
Refreshes resource availability mid-executionNo (Outside the scope of this rule)
Detects conflicts between concurrent running ORsNo (Outside the scope of this rule)

 

The resulting overlap is not a policy violation or misconfiguration. It is a data race condition where two independent processes schedule the same physical resources into identical time windows.

Решение

Stagger the Optimization Request schedules for any Service Territories that share a pool of Service Resources.

Step-by-Step Implementation:

  1. Identify Overlaps: Map out all Service Territories that share the same Service Resources (Primary or Secondary).

  2. Prioritize Primary Territories: Schedule the OR for the primary/high-priority territory to execute first.

  3. Introduce a Buffer: Ensure there is sufficient separation between start times. Apply a buffer of 20–30 minutes after the typical completion time of the first OR before starting the next.

Schedule ModelOR 1 (Territory 1) StartOR 2 (Territory 2) StartResult
Before (Problematic)01:00 AM01:00 AMRace condition & overlapping appointments.
After (Recommended)01:00 AM01:30 AMClean execution. OR 2's snapshot captures OR 1's committed changes.

By staggering the ORs, the second OR takes a snapshot that already reflects the first OR's committed changes, eliminating the race condition.


Номер статьи базы знаний

005387523

 
Загрузка
Salesforce Help | Article