"We can't debug code we don't see."
Thanks for wanting to help me but I can't show company code. I had to handwrite this version, renaming all the columns, to comply with company policy. But the SP really is pretty simple - it's pretty much the code that I showed you.
I'm not expecting a necessarily "correct" answer - just hoping that experts like you would brainstorm for possibilities that I haven't thought of.
"But I like to add that beside that there is an error in the cloning code..."
If you're referring to any typos, that's probably because I hand-wrote the code for this post.
"... the issue could also be that one more row was added to the source while the operation is running, and that is why you get the error in validation."
Not likely that a row got added late. The Evaluator-1 rows come from an original Criterion table and, in each case, the correct number of Evaluator-1 rows exist with Pass or Fail. If a row got added late, the Pass/Fail column on the new row would be null. And we have plenty of validations preventing Evaluator-1 from submitting his work if he hasn't marked all, say, 30 rows. Only when he has finished all 30 rows does the evaluation go into the senior queue where Evaluator-2 can find it and begin working on it. Evaluator-2 assigns the evaluation to himself, and then TRIES to open a web page to begin working on it. That's when the cloning happens. In these cases, Evaluator-2 has never been able to open the page, not even once, because the cloning-SP throws the exception, "Error in cloning". Instead of a page containing 30 items, all he sees is an error message.
Also, if a row got added late, we would see out-of-sequence numbers. The dbo.Workspace table has an integer identity column as primary key. We checked for numbers of out sequence but didn't find any,
As I now recall, it was in virtue of sequencing that we pretty much ruled out the idea that Evaluator 2 lost a row at some point. To summarize:
- Seems no row got added late.
- No row got deleted.
Therefore: Seems the cloning process simply failed to copy one of the rows.
What transaction isolation level are you using?
Does this happen every time, or does it happen occasionally?