Skip to content

ByteBufferIndexWriter#writeFloats does not move buffer's position pointer #606

@michaeljmarshall

Description

@michaeljmarshall

When trying to upgrade to 4.0.0-rc.7, my cassandra tests are failing with this stack trace:

Caused by: java.lang.IllegalStateException: Record size mismatch for ordinal 0: expected 2136 bytes, wrote 1736 bytes
	at io.github.jbellis.jvector.graph.disk.NodeRecordTask.call(NodeRecordTask.java:171)
	at io.github.jbellis.jvector.graph.disk.ParallelGraphWriter.lambda$writeL0Records$0(ParallelGraphWriter.java:217)
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:264)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java)
	at --- Async.Stack.Trace --- (captured by IntelliJ IDEA debugger)
	at java.base/java.util.concurrent.FutureTask.<init>(FutureTask.java:132)
	at java.base/java.util.concurrent.AbstractExecutorService.newTaskFor(AbstractExecutorService.java:108)
	at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:139)
	at io.github.jbellis.jvector.graph.disk.ParallelGraphWriter.writeL0Records(ParallelGraphWriter.java:200)
	at io.github.jbellis.jvector.graph.disk.OnDiskGraphIndexWriter.writeL0RecordsParallel(OnDiskGraphIndexWriter.java:269)
	at io.github.jbellis.jvector.graph.disk.OnDiskGraphIndexWriter.write(OnDiskGraphIndexWriter.java:210)
	at org.apache.cassandra.index.sai.disk.vector.CompactionGraph.flush(CompactionGraph.java:532)
	... 83 more

The issue seems to be in the ByteBufferIndexWriter#writeFloats. By calling asFloatBuffer(), we're creating a new object with its own position tracking, and as a result, putting the float[] moves the FloatBuffer's position, but not the source Buffer position.

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions