Closed
Description
Mateusz Stefek opened DATAMONGO-2113 and commented
startAt = changeStreamOptions.getResumeTimestamp().map(Instant::toEpochMilli).map(BsonTimestamp::new)
.orElse(null);
This is not how an Instant
should be converted into a BsonTimestamp
, as Bson timestamps are 64 bit values with a special encoding: https://docs.mongodb.com/manual/reference/bson-types/#timestamps
As a result of this bug the following request is not able to read changes from the past hour:
ChangeStreamRequest<MyDocument> request = ChangeStreamRequest.builder(messageListener)
.collection("myDocuments")
.resumeAt(Instant.now().minus(1, HOURS))
, but when I pass a fabricated Instant to resumeAt, mongo sends all the changes:
ChangeStreamRequest<MyDocument> request = ChangeStreamRequest.builder(messageListener)
.collection("myDocuments")
.resumeAt(Instant.ofEpochMilli((System.currentTimeMillis() / 1000 - 3600) << 32))
Affects: 2.1.1 (Lovelace SR1)
Issue Links:
- DATAMONGO-2115 Ability to resume ChangeStream at a given cluster timestamp given as BsonTimestamp
Referenced from: pull request #615
Backported to: 2.1.2 (Lovelace SR2)