hpcc-systems/HPCC-Platform — pull request #950 by jakesmith (2011-11-11 17:13:44+00:00)
Title: swapSuper bypassing transaction and deadlocking

This is a fix for gh-927

The swapsuper transaction commit phase, bypassed the transaction when
looking up the files it was adding back into the supers.
Therefore if those sub files were used elsewhere in the transaction,
and hence locked, swapsuper would stall.

There are a couple of other issues here, all related

1) swapSuper fix worked in transaction, but SuperOwner failed to be commited outside a transaction.
2) addSubFile could lockup, if processing a subfile already present in another
3) AddSubFile(super1, super2, addcontents) - would lockup trying to alter properties of a file it had locked

These are caused by same issue(s).

1) It's not supposed to commit anything unless it had a psueudo lock on the files properties (lockProperties())
In the past SuperOwner was bypassing that - AND it was lucky to get away with, because it had a read lock, not a write lock as it would with all other changes, so it was lucky Dali is lenient to allow commits on non write locks.
2) It wasn't consistently referencing the transaction to lookup files, which was causing it to lookup multiple times and keep multiple readlocks, which could lead to deadlock. A related issue was 3) - which whether inside or outside a user transaction needed to reference the same files/locks as it was altering.

Signed-off-by: Jake Smith