jruby timestamps only have millisecond accuracy which can result in timestamp collision
Description
cql_byte_buffer.rb uses the following to create the microsecond timestamp:
def append_timestamp(timestamp) append_long(timestamp.tv_sec * 1000000 + timestamp.tv_usec) end
The timestamp is created by calling ::Time.now
This is fine for standard ruby where Time.now returns a microsecond accurate time. However, if the client is using jruby Time.now returns a millisecond accurate time which makes it fairly likely that multiple queries will resolve to the same timestamp making for some rather interesting debugging...
Environment
None
Pull Requests
None
Activity
Show:
Sandeep Tamhankar April 28, 2016 at 5:40 PM
That's strong enough evidence. Thanks!
Shannon Holland April 28, 2016 at 4:45 PM
I haven't done an explicit test but I first noticed the core issue (inserts silently failing) back when we were using version 2.1.5 of the driver.
Sandeep Tamhankar April 28, 2016 at 4:28 PM
Thanks for the detailed feedback on this. I suspect this issue also existed in previous versions of the driver, but wanted to check if you happened to have tried it.
cql_byte_buffer.rb uses the following to create the microsecond timestamp:
def append_timestamp(timestamp)
append_long(timestamp.tv_sec * 1000000 + timestamp.tv_usec)
end
The timestamp is created by calling ::Time.now
This is fine for standard ruby where Time.now returns a microsecond accurate time. However, if the client is using jruby Time.now returns a millisecond accurate time which makes it fairly likely that multiple queries will resolve to the same timestamp making for some rather interesting debugging...