status_changed_time can go back in time

Bug #1235420 reported by Bill Ott
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Evergreen
Triaged
Medium
Rogan Hamby

Bug Description

Evergreen 2.2
psql 9.1

I discovered items changing from reshelving to available much too quickly and seemingly randomly. I tracked the problem back to the status_changed_time coinciding with the copy's checkout time instead of its checkin time.

I further realized that this seemed to be isolated to floating items.

I verified in the audit tables that the status_changed_time was getting set backward. It seems that when copies are updated when floated, the update applies the entire copy object, which contains a stale status_changed_time. However, since the status is not changing, the trigger is ignored and the previous status_changed_time is returned.

I believe the answer is to change the trigger function to not allow the status_change_time to revert to an earlier date.

Tags: cataloging
Revision history for this message
Bill Ott (bott) wrote :

The attached patch should prevent updates from applying an older status_changed_time than the existing value.

Revision history for this message
Bill Ott (bott) wrote :

Missed colon in the assignment in the previous patch!

Revision history for this message
Bill Ott (bott) wrote :

Thinko in previous patch. We only want to keep the old time if we're not resetting it to now().

Revision history for this message
Jason Stephenson (jstephenson) wrote :
Revision history for this message
Jason Stephenson (jstephenson) wrote :

I should add that the point of the branch and bug that I added above are so that the status_changed time can go back in time.

I will see if I can reproduce the behavior reported by Bill in current master when I get a chance, which may mean never.

Revision history for this message
Jason Stephenson (jstephenson) wrote :

Further investigation leads me to believe that the better fix is to alter the code where the stale copy object is used so that it's status_changed_time is updated before the database representation is updated.

Revision history for this message
Bill Ott (bott) wrote :

I hadn't caught your change for bug 1220389. However, that wouldn't apply in this case, as the status is not changing. The copy floats after the check-in, so the NEW and OLD are both effectively 7, bailing immediately from the IF.

Refreshing the object prior to updating would be an option, although it requires another call to pull the data, and it leaves me with the question, is this the only place this phenomenon can occur?

Because this case is unique, in that it occurs when statuses are not really changing, it could coexist with your proposed change to the function.

Ben Shum (bshum)
Changed in evergreen:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Josh Stompro (u-launchpad-stompro-org) wrote :

Hello, I just ran into this issue with EG 2.10.6.

I can replicate it by doing a checkout without checkin. Checking out an item that is currently checked out, to someone else without checking it in first.

I noticed this because we were looking for issues with the reshelving complete script, where items go from checked out -> reshelving -> checked out -> available. In a few cases (3) when the reshelving complete script was run at the same time as the no-op checkin, the reshelving complete script grabbed the item because of the status_change_time being set back to the last checkout date.

So I can get it to trigger in two cases. Floating to a different branch, or doing a no-op checkin at the same branch.

Josh

tags: added: cataloging
Revision history for this message
Rogan Hamby (rogan-hamby) wrote :

Looking at this I agree with Jason that looking at the stale copy object is probably the better approach here. I'm assigning this to myself for now. I'm not sure I'll have time this week to look at it more but it doesn't appear to be a major point given the lack of activity on it.

Changed in evergreen:
assignee: nobody → Rogan Hamby (rogan-hamby)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.