Hi Team,
Please MS documentation states (https://msdn.microsoft.com/en-us/library/ff878253.aspx)
The DBCC SHRINKFILE operation on files containing disk-based tables might fail on the primary replica if the file contains ghost records that are still needed on a secondary replica.
It means by default shrinkfile is reliant on Ghost cleanup task and forces it to run when we shrink file/database.
Thank you very much team.