Serial is consumed inside of transaction block when transaction fails

Let’s have a workflow with transaction behaviour Ignore and let’s have an atomic transaction block inside of it. Let’s perform following transformation inside the block:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
	xmlns:AS="http://schema.advantages.cz/AsapFunctions"
	xmlns:date="http://exslt.org/dates-and-times" exclude-result-prefixes="AS date">

	<xsl:template match="/">
		<Test
			Id="{AS:GenerateId()}"
			Serial="{AS:GenerateSerial('INVOICE')}"
			Lookup="{AS:LookupValue('fb264a02-2308-4e80-b789-cd40da44b7c1', '')}"/>
	</xsl:template>
</xsl:stylesheet>

The attribute Serial consumes counter, but attribute Lookup causes failure because there’s no value provided to lookup. As a result the workflow fails, but the counter remains incremented.

I’d expect counter to not be consumed.

An observation

The problem happens only in this specific setup. If the workflow transaction behaviour is InheritExisting, the counter is not consumed.