Platform
Asynchronous sharing recalculation: what breaks in your Apex and Flow
Salesforce now recalculates some sharing in the background after a group or role change, and a Release Update enforces it in Spring 27. Code that reads a share record the instant it changes membership can break. How to find that code and fix it before the switch flips.
Your org has a Release Update that most teams scroll right past. Its name is “Update Apex Code and Flows for Changed Sharing Recalculation Behavior.” Then a nightly job that reassigns territories starts failing one row in fifty, an Apex test that passed for three years goes red, and nobody connects it to a setting they never touched.
The change underneath is small and specific. Salesforce now recalculates some sharing in the background instead of the instant you change a group or a role. If your code reads a share record the moment after it moves someone between groups, it can read a record that is not there yet.
The fix is to stop assuming the share exists and confirm it first. That is the whole post, and the rest is how to find the code that assumes wrong before Salesforce enforces the switch for you.
The enforcement date matters, so start there. Salesforce’s release notes say this update enforces in Spring ‘27, and it has been available to enable since Spring ‘26. Enforcement dates move, so the authority is the Release Updates node in your own Setup, not this post. But treat Spring ‘27 as the clock you are racing.
What changed
When you delete a public group, change its membership, or update a role, Salesforce recalculates sharing so record access stays correct. That recalculation used to finish inside the same transaction. Now, per Salesforce’s knowledge article, related owner-based sharing rules and account-owner share records are recalculated asynchronously when the system decides that performs better.
Two precise points keep this from being scarier than it is.
The group or role change itself still happens synchronously. The downstream recalculation of owner-based sharing rules and account-owner shares is the part that may move to the background. So the membership is updated when your DML returns. The share records that membership implies might lag.
And the choice is dynamic, not a fixed rule. Salesforce says the decision depends on factors including the ownership of the affected users and available database resources, and that synchronous recalculation still happens in many cases. There is no published row count or group size that flips it. That is the hard part: the behaviour is non-deterministic, so code that depends on the timing works until the day it doesn’t.
Only some orgs will feel it, but they will feel it badly
This does not hit every org, which is exactly why it is easy to dismiss and expensive to ignore. Salesforce’s criteria are specific, and an org has to meet all of them to be exposed.
Three conditions, all required. Large data volumes with high ownership skew, where a few users or queues own enormous numbers of records. Apex or Flows that modify group membership or roles. And Apex or Flows that then rely on the updated share records being available immediately.
If that is your org, it shows up in one particular place: the automation that reorganises access. Territory realignment. A nightly job that moves users between role hierarchies. An onboarding Flow that adds someone to a public group and then checks what they can see. A data load that reassigns ownership in bulk and reconciles sharing in the same run.
These are the routines that change membership and read the result in one breath, and they are the ones that will break.
The two failure patterns to grep for
Salesforce names two concrete ways code breaks, and both are worth searching your codebase for today.
The first is a query or assertion on share records that expects them to exist right away. A sharing rule creates share rows with the row cause Rule, so code like this is the trap:
// Reassign the account owner, then expect the rule-based share to exist.
update accountsToReassign;
List<AccountShare> shares = [
SELECT Id, UserOrGroupId
FROM AccountShare
WHERE AccountId IN :accountIds
AND RowCause = 'Rule'
];
// shares can come back empty now: the recalculation hasn't run yet.
System.assert(!shares.isEmpty(), 'Expected rule shares');
Under the old behaviour, the share rows were there by the time the query ran. Under the new one, the recalculation may still be queued, the list comes back empty, and the assertion or the logic that follows it falls over.
The second pattern lives in your tests. Salesforce states plainly that System.runAs() will not reflect a user’s expected access until the asynchronous recalculation completes. So an Apex test that changes a user’s role or group, then opens a System.runAs block and asserts the user can now see a record, can fail intermittently.
Intermittent is the worst kind of red, because it passes on the rerun and teaches the team to rerun instead of fix.
Turn on the test setting and let your tests tell you
You do not have to guess which classes are exposed. Salesforce ships a switch that forces the asynchronous path during Apex tests so the fragile ones fail on purpose.
On the Sharing Settings page there is a setting called “Test asynchronous sharing recalculation in Apex tests.” Turn it on, run your full suite, and read the failures. Each failing test is pointing at code that assumes synchronous recalculation and needs updating. The red is the deliverable here, so resist the urge to make it green the fast way.
Work through the failures, fix the code, then turn the setting back off so it stops forcing the async path and creating noise once you are done. You are doing what any Release Update asks: using a controlled switch to surface the problem in a sandbox on your schedule instead of in production on Salesforce’s.
Do this in a sandbox that resembles production, because the whole premise of the change is data volume and ownership skew. A near-empty developer sandbox will not reproduce the condition that triggers async recalculation in the first place, and a green suite there proves less than it looks.
Our note on choosing the right sandbox covers why a full or partial copy earns its cost for exactly this kind of volume-sensitive testing.
How to fix the code
The remediation is the same everywhere: stop treating a membership change and its share records as one atomic step. Confirm the shares exist before you depend on them, and if they do not yet, do the dependent work after they do rather than inside the same transaction.
For logic that needs the new access, the clean pattern is to hand the follow-up work to a separate transaction that runs after the recalculation has had a chance to finish. A Queueable is the natural fit, because it runs after the current transaction commits and can re-check for the share rows before proceeding:
public class VerifyAccess implements Queueable {
private Set<Id> accountIds;
public VerifyAccess(Set<Id> accountIds) { this.accountIds = accountIds; }
public void execute(QueueableContext ctx) {
List<AccountShare> shares = [
SELECT Id FROM AccountShare
WHERE AccountId IN :accountIds AND RowCause = 'Rule'
];
if (shares.isEmpty()) {
// Recalculation may still be running; re-check later, bounded.
return; // re-enqueue with a counter, or schedule a follow-up
}
// Safe to run the work that depends on the new access.
}
}
Salesforce’s own guidance stops at the principle: confirm the share records are updated before continuing, rather than assuming they already exist. The Queueable re-check is a reasonable way to implement that principle, not a step Salesforce prescribes, so bound the attempts and fail loudly after a few rather than re-enqueueing forever.
That bounded-retry instinct is the same one that keeps UNABLE_TO_LOCK_ROW retries from turning into a denial-of-service against your own org, and the reasoning carries over cleanly.
For tests, the fix is to assert on the share records rather than on immediate access through System.runAs. Check that the expected AccountShare rows exist as the signal that recalculation finished, and structure the test so it does not depend on access being live the instant the membership changed.
A test that asserts the mechanism, not the timing, is the kind of test that survives a platform change, which is the broader point we make about Apex tests that assert.
Watch the recalculation instead of guessing
When a bulk change does kick off a background recalculation, you can watch it rather than wonder. From Setup, enter Background Jobs in the Quick Find box and open Background Jobs. The page shows the running recalculation with a percentage estimate, a Job Type column for the operation, and a Job Sub Type column for the object and phase.
Admins also get an email when recalculation completes across the affected objects, and sharing operations are logged in the Setup Audit Trail.
One caveat that catches people on this page: a job listed as Completed does not always mean every downstream change is reflected yet. Additional operations can still finish after the status flips, so Completed is a strong signal, not a guarantee. If you are scripting a cutover around a large reorganisation, build in margin rather than treating Completed as a green light to fire the next step.
For the planned large changes, there is an older tool worth knowing: Defer Sharing Calculations lets an admin suspend recalculation around a big batch of membership or role changes and resume it once, which avoids a storm of overlapping recalculations. Deferring group membership calculations specifically is not on by default and has to be requested through Salesforce support. Neither feature makes the asynchronous behaviour go away, but both give you control over when the recalculation runs, which is often what you want during a migration weekend.
What I would do before Spring ‘27
Three steps, in order, and none of them needs to wait for the enforcement date.
Find the code first. Search for Apex and Flows that change group membership, role, or ownership and then read a __Share object, call System.runAs, or branch on record access in the same transaction. That list is your exposure, and it is almost always shorter than the fear suggests.
Then let the platform grade you. Turn on “Test asynchronous sharing recalculation in Apex tests” in a volume-realistic sandbox, run the suite, and fix every test that goes red by confirming the shares exist before depending on them. Turn the setting back off when you are done.
Then enable the Release Update itself in that sandbox and exercise the real routines, the territory realignment and the onboarding Flow, against production-shaped data before you let the clock enforce it for you. Access and sharing design is unforgiving precisely because the failures are quiet and intermittent, which is why untangling it is a steady part of our managed services and org-rescue work. The switch is coming either way. The only choice is whether you flip it on your schedule or Salesforce flips it on theirs.
Understanding the basics
What is asynchronous sharing recalculation in Salesforce?
After a group deletion, group membership change, or role update, Salesforce recalculates the sharing that controls record access. Some of that recalculation, specifically for owner-based sharing rules and account-owner share records, now runs in the background instead of finishing in the same transaction, when Salesforce determines that performs better. The group or role change itself still happens synchronously; the share records it implies may lag behind.
When does Salesforce enforce the sharing recalculation Release Update?
Salesforce’s release notes schedule the “Update Apex Code and Flows for Changed Sharing Recalculation Behavior” update for enforcement in Spring ‘27, and it has been available to enable since Spring ‘26. Enforcement dates can shift, so confirm the current date in the Release Updates node of your own org’s Setup rather than relying on any blog.
How do I test whether my Apex breaks under asynchronous sharing recalculation?
Enable “Test asynchronous sharing recalculation in Apex tests” on the Sharing Settings page, then run your test suite. Failing tests indicate code that relies on synchronous recalculation and needs updating. Fix each one so it confirms the expected share records exist before depending on them, then turn the setting off. Do this in a sandbox with realistic data volume, because the async path is more likely to trigger under high ownership skew.
Which orgs are affected by this change?
Only orgs that meet all of Salesforce’s criteria: large data volumes with high ownership skew, Apex or Flows that modify group membership or roles, and Apex or Flows that rely on the updated share records being available immediately. Most orgs that are exposed feel it in access-reorganisation automation such as territory realignment, onboarding flows, or bulk ownership reassignment.
Finding the automation that reads a share record the instant it changes membership, and fixing it before a Release Update turns intermittent failures into nightly ones, is the kind of access and technical-debt work our implementation and managed-services practice does on real orgs. If a sharing change is making your jobs or tests flaky, talk to us.