View Issue Details

IDProjectCategoryView StatusLast Update
0002076SymmetricDSBugpublic2014-12-01 12:26
ReporterxBlackCat Assigned Tochenson  
Prioritynormal 
Status closedResolutionfixed 
Product Version3.6.12 
Target Version3.6.14Fixed in Version3.6.14 
Summary0002076: Synchronization is not performed if datetime column has changes in fractional seconds part
DescriptionWe are using DATETIME with fractional seconds (MySQL 5.6.21) in our database.
There is setup a conflict resolving rule USE_TIMESTAMP on a table column of DATETIME(6) type.
When we update the column value on 0.1 second, row is not sending to other servers and if we change the column value on 1 second - row is sent.

Possibly there is a fractional part truncation for datetime type values comparation for determining if data should be sent or not.
TagsNo tags attached.

Activities

xBlackCat

2014-11-20 08:13

reporter   ~0000600

UPD: I see all update packets in source database in sym_data table but in the destination database the sym_data table has only packets with changes in second but no packets with changed fractional part of seconds

xBlackCat

2014-11-20 12:24

reporter   ~0000601

The reason of the behavior in the following line of code (DefaultDatabaseWriterConflictResolver.java:101):

        return existingTs == null || loadingTs.after(existingTs);

Where loadingTs and existingTs variables of java.util.Date type referenced to java.sql.Timestamp objects.

Methods .after() and .before() works improperly for Timestamp objects. Please, see the provided example:
{
        Date d1 = Timestamp.valueOf("2014-11-20 09:24:38.3008");
        Date d2 = Timestamp.valueOf("2014-11-20 09:24:38.4009");

        System.out.println("After: " + d2.after(d1));
        System.out.println("Before: " + d2.before(d1));
        System.out.println("Equals: " + d2.equals(d1));
        System.out.println("CompareTo(d2 > d1): " + d2.compareTo(d1));
        System.out.println("CompareTo(d1 > d2): " + d1.compareTo(d2));
}
As result we got:
------------------------------
After: false
Before: false
Equals: false
CompareTo(d2 > d1): 1
CompareTo(d1 > d2): -1
------------------------------

The solution is use compareTo() method for Date variables instead of before()/after() to deal with microseconds in correct way.

chenson

2014-11-20 13:37

administrator   ~0000602

Thanks for the tip. We'll get this fixed.

Related Changesets

SymmetricDS: master c02170aa

2014-11-20 15:42:21

chenson

Details Diff
0002076: Synchronization is not performed if datetime column has changes in fractional seconds part Affected Issues
0002076
mod - symmetric-io/src/main/java/org/jumpmind/symmetric/io/data/writer/DefaultDatabaseWriterConflictResolver.java Diff File

Issue History

Date Modified Username Field Change
2014-11-19 15:11 xBlackCat New Issue
2014-11-20 08:13 xBlackCat Note Added: 0000600
2014-11-20 12:24 xBlackCat Note Added: 0000601
2014-11-20 13:37 chenson Note Added: 0000602
2014-11-20 13:37 chenson Target Version => 3.7.0
2014-11-20 13:44 chenson Fixed in Version => 3.6.14
2014-11-20 13:44 chenson Target Version 3.7.0 => 3.6.14
2014-11-20 13:44 chenson Status new => resolved
2014-11-20 13:44 chenson Resolution open => fixed
2014-11-20 13:44 chenson Assigned To => chenson
2014-11-20 14:00 chenson Changeset attached => SymmetricDS 3.6 r8952
2014-11-20 21:00 chenson Changeset attached => SymmetricDS trunk r8954
2014-12-01 12:26 chenson Status resolved => closed
2015-07-31 01:49 chenson Changeset attached => SymmetricDS master c02170aa