Assume that you use Microsoft SQL Server 2016 or 2017. When you run some queries with batch mode operations and a spill to TempDB happens, SQL Server may encounter a non-yielding scheduler issue. When the database is part of an Always On availability group (AG), a failover occurs.
This issue is fixed in the following cumulative updates for SQL Server:
About cumulative updates for SQL Server:
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server: