Image the following scenario,
- You have 10 Java applications accessing a database server
- Each application servers have been running for some time, and the Java applications time are now few minutes apart
- 1 application inserts a record using the current time as the record effective date
- Another application retrieves the record and compare开发者_运维技巧 the effective date with its current time
In the above scenario, even though your application logic may sound correct, and when it is running in production environment, thing will go wrong.
How can i solve this?
Use NTP to synchronise the times of the machines.
If that's not an option for some reason, use only the server's date and time (for example, by using SQL's NOW
function or similar both in inserts and as an extra column in selects).
精彩评论