function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SFDC_KMSFDC_KM 

System.UnexpectedException: commits are not allowed because someone called setCommitAllowed(false), justification: doWorkAndCommit

I am calling a batch in trigger where I am getting 'System.UnexpectedException: commits are not allowed because someone called setCommitAllowed(false), justification: doWorkAndCommit' error while bulk update. In debug logs the error is indicated for line no underlined below.
if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR Status = 'Preparing' OR Status = 'Queued')] < 5){
	ID batchprocessid = Database.executeBatch(new batchClass(contactIds),100);
} else{
		ID batchprocessid = Database.executeBatch(new batchClass(contactIds),100);
		Boolean isSuccess = System.FlexQueue.moveJobToFront(batchprocessid);
		system.debug('---batchprocessid: '+batchprocessid+' & movedToFront: '+isSuccess);
}
Can anyone lead me to the reason for this exception?