Bug 4282

Summary: Checkpoint and application updates should be in the same transaction
Product: jbatch Reporter: mminella
Component: sourceAssignee: cvignola
Status: CLOSED FIXED    
Severity: normal CC: issues, ScottKurz
Priority: P5    
Version: 1   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description mminella 2012-11-09 21:39:50 UTC
Per section 6.7, the default behavior is to commit the application data and the checkpoint information in separate transactions.  This means that the default behavior allows the condition of the application's true state being out of sync from the stored state.  The default should be that these occur in the same transaction.
Comment 1 ScottKurz 2012-11-12 17:28:31 UTC
A downside of defaulting to 'true' is that the transactional behavior won't take affect, by default, in an SE environment.   But, given that the spec mentions this is just an intent, it would be a fine choice as well.  

I could go either way.
Comment 2 cvignola 2012-11-17 20:04:15 UTC
Yeah,  trying to thread the needle between SE and EE environments ...

In an SE environment there is simply no guarantee of a XA transaction manager.  So in SE, you get what you get unless you add in JOTM or something comparable. 

But I agree the default is the wrong default.  The default should be XA - if possible.  The opt-out should be local mode.  

So the spec should say something like:

The runtime will attempt to use global transaction mode by default.  But this can only be guaranteed by the Java environment in which the batch runtime is executing. This guarantee is assured by a Java EE environment;  it can only be assured in a Java SE environment if the environment has been configured with an XA tranaction manager. 

A batch step may be executed in local transaction mode,  if desired, by setting step level property: 

javax.transaction.global.mode=false

Note when running in local mode (i.e. global mode is false) application updates and batch runtime checkpoints are not in the same transactional scope.  

Note also that even when global mode is true, that application updates and batch runtime checkpoints are in the same transactional scope if and only if the hosting Java environment supplies an XA transaction manager.
Comment 3 cvignola 2013-01-16 16:15:21 UTC
checkpoint and application updates are in same transaction in EE environment through use of global tran.  not true of SE,  since tran manager is not required on that platform. An implementer is free to accomodate global transaction in SE but is not required to by spec.