I had a similar problem when I was trying to set up an all or nothing write to our DB. What fixed it for me was the first query in the transaction (after getting the transaction ID) needed to have the project argument filled. Subsequent named query calls do not need that parameter filled.
This worked:
txID = system.db.beginNamedQueryTransaction(project="project1", database="database1")
try:
system.db.runNamedQuery(project="project1", path="query1", params=params1, tx=txID)
#do some stuff
system.db.runNamedQuery(path="query2", params=params2, tx=txID)
# do more stuff
system.db.commitTransaction(txID)
except:
system.db.rollbackTransaction(txID)
finally:
system.db.closeTransaction(txID)
but this would not work, for whatever reason:
txID = system.db.beginNamedQueryTransaction(project="project1", database="database1")
try:
system.db.runNamedQuery(path="query1", params=params1, tx=txID)
#do some stuff
system.db.runNamedQuery(path="query2", params=params2, tx=txID)
# do more stuff
system.db.commitTransaction(txID)
except:
system.db.rollbackTransaction(txID)
finally:
system.db.closeTransaction(txID)