I need help in resolving the below issue.
I have a community plus user. The user is part of public group and the group has read/write access to all contact records and read access to account records in the entire org using Sharing Rules. This setup was working fine till winter 19.
Specifically SOQLs that read contacts that belongs to “accounts not linked to community user (AccountId in User table) ” were working fine.
After winter 19 release, the soql running as community plus login user runs very slow specifically while quering contacts that does not belong to Accounts that are not directly linked to the community plus user record on User table. I was able to reproduce the issue with below Test code.
@isTest(SeeAllData=true) public class Test_Winter19 { static testMethod void demonstrate() { User u = [Select Id,AccountId from User where userName = '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c0aaa2a1b980a6adeea3afad">[email protected]</a>']; Id accRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('Seller Servicer Account').getRecordTypeId(); account acc = [Select Id from Account where id = '0014D000009yfeUQAQ']; contact con = new contact(FirstName = 'different', LastName = 'Account', email = '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4d0ddd2d2d1c6d1dac0f4d0ddd2d2d1c6d1dac0f5d7d7dbc1dac09ad7dbd9">[email protected]</a>', AccountId = acc.Id); contact con1 = new contact(FirstName = 'same', LastName = 'Account', email = '<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="27525442556752544255464444485249530944484a">[email protected]</a>', AccountId = u.AccountId); insert con; insert con1; System.runAs(u) { System.debug('*****************trying to read different account contact***************'); Long startTime = DateTime.now().addDays(-1).getTime(); //Contact diffAccContact = [Select Id from Contact where email='<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bbdfd2dddddec9ded5cffbdfd2dddddec9ded5cffad8d8d4ced5cf95d8d4d6">[email protected]</a>']; Long endTime = DateTime.now().addDays(-1).getTime(); Long milliseconds = endTime - startTime; Long seconds = milliseconds / 1000; System.debug('*****************completed read different account contact***************'); System.debug('total time taken -- ' + seconds +' seconds'); System.debug('*****************trying to read same account contact***************'); startTime = DateTime.now().addDays(-1).getTime(); Contact sameAccContact = [Select Id from Contact where email='<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="097c7a6c7b497c7a6c7b686a6a667c677d276a6664">[email protected]</a>']; endTime = DateTime.now().addDays(-1).getTime(); milliseconds = endTime - startTime; seconds = milliseconds / 1000; System.debug('*****************completed read same account contact***************'); System.debug('total time taken -- ' + seconds + ' seconds'); } } }
Below is screenshot of debug logs for time taken when running the test class from dev console.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
Salesforce R& D confirmed it as winter defect. They are applying patch on Oct 9th in winter sandboxes.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0