Mark Goodrich
unread,Feb 4, 2014, 9:32:15 AM2/4/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to d...@openmrs.org
We've been looking to upgrade from mysql 5.5 to 5.6 because we've seen
significant performance improvement for some of our reports (some
reports that took hours on 5.5 take seconds on 5.6). However, we just
upgraded one of our staging servers to 5.6 and discovered an annoying
complication.
Evidently, 5.5 only supports DATETIME with precision to the nearest
second. Starting in 5.6, milliseconds are supported up to 6 digits of
precision. However to support backward compatibility, by default in 5.6
DATETIMEs are still only stored to the nearest second. We want
backwards compatibility, so so far so good....
The problem is that there is a change in the way mysql handles saving
DATETIMEs that it receives with a millisecond component. In 5.5, it
simply drops the millisecond component, while in 5.6 it rounds. The
problem with this is that since java Dates go to the millisecond, if you
save a date and then immediately retrieve it in a new session, you can
run into (and we are seeing) issues like this:
Date someDate = new Date()
(save someDate, [if ms >.500, mysql rounds up], close session)
(new session, retrieve someDate)
someDate.after(new Date()) == true
Specifically, we are running into a problem on the Mirebalais patient
dashboard where if you click the "start a new visit" button, on page
reload the system doesn't always display the visit as being open. I
would also guess we might start seeing some failing validation issues in
places are well (shouldn't normally be a problem, but any object that is
reloaded and then resaved less than a second after creation, it is
possible).
Thoughts? We haven't found any documentation online yet as to how to
modify this behaviour. Obviously for backwards compatibility reasons,
changing all the DATETIME fields so that they store milliseconds is a
non-starter. The only idea we have so far is to just make sure we zero
out the millisecond component of encounterDate, visitDate, etc, when
saving. It's possible that Hibernate might be able to help us... we
need to research a little more in that area.
Take care,
Mark