[ 
https://issues.apache.org/jira/browse/CASSANDRA-19349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Andreas Mager updated CASSANDRA-19349:
--------------------------------------
    Description: 
{{I have stumbled over a wired problem on my pc.}}

{{When i turn on my wifi interface, then some of my integration test are 
failing.}}

{{The mac part(lsb) of the timeuuids become changed in our Uuid 
implementation.}}

{{These uuids are used for the cassandra insertions and queries.}}

 

{{TestSetup with "broken" Uuids:}}
{code:java}
CREATE TABLE object_comment (
    object timeuuid,
    comment timeuuid,
    value blob,
    PRIMARY KEY (object, comment)
)

INSERT INTO object_comment (object, comment , value) VALUES 
(95278adc-c03f-11ee-ab43-bb35e932d536, cf9e6440-c01e-11ee-847b-34cff6b1be80, 
0x01);
INSERT INTO object_comment (object, comment , value) VALUES 
(95278adc-c03f-11ee-ab43-bb35e932d536, cf9f75b0-c01e-11ee-847b-34cff6b1be80, 
0x02);

// cf9f75b0-c01e-11ee-847b-34cff6b1be7f is lsb-1 and the same timestamp
SELECT * FROM object_comment where object = 
95278adc-c03f-11ee-ab43-bb35e932d536 AND comment <= 
cf9f75b0-c01e-11ee-847b-34cff6b1be7f; object                               | 
comment                              | value
--------------------------------------+--------------------------------------+-------
 95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 |  
0x01
 95278adc-c03f-11ee-ab43-bb35e932d536 | cf9f75b0-c01e-11ee-847b-34cff6b1be80 |  
0x02(2 rows)
 {code}
 

 

The second row must not be present. The Only row expected is : 
{code:java}
95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 |  
0x01{code}
 

I think i have found the cause of the issue.

The Methods `org.apache.cassandra.utils.TimeUUID#compareTo` and 
`org.apache.cassandra.db.marshal.TimeUUIDType#compareCustom` return different 
results.

Test pseudocode:
{code:java}
var id = UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be80");
var idDecrementInLsb = UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be7f");

// java.util.UUID#compareTo
assertThat(idDecrementInLsb.compareTo(id)).isEqualTo(-1);

var timeUuidDec = 
org.apache.cassandra.utils.TimeUUID.fromUuid(idDecrementInLsb);
var timeUuidId = org.apache.cassandra.utils.TimeUUID.fromUuid(id);

// org.apache.cassandra.utils.TimeUUID#compareTo
assertThat(timeUuidDec.compareTo(timeUuidId)).isEqualTo(-1);

// org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom
assertThat(org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom(idDecrementInLsb,
 id1)).isEqualTo(-1); // This fails
 {code}
 

  was:
{{I have stumbled over a wired problem on my pc.}}

{{{}{{When i turn on my wifi interface, then some of my integration test are 
failing.}}{}}}{{{}{{The mac part(lsb) of the timeuuids become changed in our 
Uuid implementation.}}{}}}

{{These uuids are used for the cassandra insertions and queries.}}

 

{{TestSetup with "broken" Uuids:}}
{code:java}
CREATE TABLE object_comment (
    object timeuuid,
    comment timeuuid,
    value blob,
    PRIMARY KEY (object, comment)
)

INSERT INTO object_comment (object, comment , value) VALUES 
(95278adc-c03f-11ee-ab43-bb35e932d536, cf9e6440-c01e-11ee-847b-34cff6b1be80, 
0x01);
INSERT INTO object_comment (object, comment , value) VALUES 
(95278adc-c03f-11ee-ab43-bb35e932d536, cf9f75b0-c01e-11ee-847b-34cff6b1be80, 
0x02);

// cf9f75b0-c01e-11ee-847b-34cff6b1be7f is lsb-1 and the same timestamp
SELECT * FROM object_comment where object = 
95278adc-c03f-11ee-ab43-bb35e932d536 AND comment <= 
cf9f75b0-c01e-11ee-847b-34cff6b1be7f; object                               | 
comment                              | value
--------------------------------------+--------------------------------------+-------
 95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 |  
0x01
 95278adc-c03f-11ee-ab43-bb35e932d536 | cf9f75b0-c01e-11ee-847b-34cff6b1be80 |  
0x02(2 rows)
 {code}
 

 

The second row must not be present. The Only row expected is : 
{code:java}
95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 |  
0x01{code}
 

I think i have found the cause of the issue.

The Methods `org.apache.cassandra.utils.TimeUUID#compareTo` and 
`org.apache.cassandra.db.marshal.TimeUUIDType#compareCustom` return different 
results.

Test pseudocode:
{code:java}
var id = UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be80");
var idDecrementInLsb = UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be7f");

// java.util.UUID#compareTo
assertThat(idDecrementInLsb.compareTo(id)).isEqualTo(-1);

var timeUuidDec = 
org.apache.cassandra.utils.TimeUUID.fromUuid(idDecrementInLsb);
var timeUuidId = org.apache.cassandra.utils.TimeUUID.fromUuid(id);

// org.apache.cassandra.utils.TimeUUID#compareTo
assertThat(timeUuidDec.compareTo(timeUuidId)).isEqualTo(-1);

// org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom
assertThat(org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom(idDecrementInLsb,
 id1)).isEqualTo(-1); // This fails
 {code}
 


> Timeuuid compare is broken
> --------------------------
>
>                 Key: CASSANDRA-19349
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-19349
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Andreas Mager
>            Priority: Normal
>
> {{I have stumbled over a wired problem on my pc.}}
> {{When i turn on my wifi interface, then some of my integration test are 
> failing.}}
> {{The mac part(lsb) of the timeuuids become changed in our Uuid 
> implementation.}}
> {{These uuids are used for the cassandra insertions and queries.}}
>  
> {{TestSetup with "broken" Uuids:}}
> {code:java}
> CREATE TABLE object_comment (
>     object timeuuid,
>     comment timeuuid,
>     value blob,
>     PRIMARY KEY (object, comment)
> )
> INSERT INTO object_comment (object, comment , value) VALUES 
> (95278adc-c03f-11ee-ab43-bb35e932d536, cf9e6440-c01e-11ee-847b-34cff6b1be80, 
> 0x01);
> INSERT INTO object_comment (object, comment , value) VALUES 
> (95278adc-c03f-11ee-ab43-bb35e932d536, cf9f75b0-c01e-11ee-847b-34cff6b1be80, 
> 0x02);
> // cf9f75b0-c01e-11ee-847b-34cff6b1be7f is lsb-1 and the same timestamp
> SELECT * FROM object_comment where object = 
> 95278adc-c03f-11ee-ab43-bb35e932d536 AND comment <= 
> cf9f75b0-c01e-11ee-847b-34cff6b1be7f; object                               | 
> comment                              | value
> --------------------------------------+--------------------------------------+-------
>  95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 
> |  0x01
>  95278adc-c03f-11ee-ab43-bb35e932d536 | cf9f75b0-c01e-11ee-847b-34cff6b1be80 
> |  0x02(2 rows)
>  {code}
>  
>  
> The second row must not be present. The Only row expected is : 
> {code:java}
> 95278adc-c03f-11ee-ab43-bb35e932d536 | cf9e6440-c01e-11ee-847b-34cff6b1be80 | 
>  0x01{code}
>  
> I think i have found the cause of the issue.
> The Methods `org.apache.cassandra.utils.TimeUUID#compareTo` and 
> `org.apache.cassandra.db.marshal.TimeUUIDType#compareCustom` return different 
> results.
> Test pseudocode:
> {code:java}
> var id = UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be80");
> var idDecrementInLsb = 
> UUID.fromString("cf9f75b0-c01e-11ee-847b-34cff6b1be7f");
> // java.util.UUID#compareTo
> assertThat(idDecrementInLsb.compareTo(id)).isEqualTo(-1);
> var timeUuidDec = 
> org.apache.cassandra.utils.TimeUUID.fromUuid(idDecrementInLsb);
> var timeUuidId = org.apache.cassandra.utils.TimeUUID.fromUuid(id);
> // org.apache.cassandra.utils.TimeUUID#compareTo
> assertThat(timeUuidDec.compareTo(timeUuidId)).isEqualTo(-1);
> // org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom
> assertThat(org.apache.cassandra.db.marshal.TimeUUIDType.compareCustom(idDecrementInLsb,
>  id1)).isEqualTo(-1); // This fails
>  {code}
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to