Fix for MONDRIAN-1506. The SQL statements for segments are now registered in the segment cache index so that we can determine if it is safe or not to cancel a given statement. I have also tightened the handling of the different exceptions to make sure that we don't let any slip. This prevents a race condition that existed when the cancelation of the SQL statements was not noticed before a second query came in and used the very same segment entry form the index. This was causing the cancelation exception to bubble (rightfully) to the second query thread.
Woopsie for MONDRIAN-1506. I had removed the small pause between the two tests but forgot to put it back in. Both tests need some distance in timing to be valid or else we create contention between them.