-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Arbitrary bytes in blob store register #96019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arbitrary bytes in blob store register #96019
Conversation
Today the blob store register supports recording only a `long`, represented as an 8-byte blob. We need to store a little more data in the register, so this commit generalises things to work with a `BytesReference` directly.
Pinging @elastic/es-distributed (Team:Distributed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, but I left a question regarding MAX_REGISTER_CONTENT_LENGTH
|
||
public class BlobContainerUtils { | ||
private BlobContainerUtils() { | ||
// no instances | ||
} | ||
|
||
public static final int MAX_REGISTER_CONTENT_LENGTH = Long.BYTES; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be greater than Long.BYTES
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was intending to do that in a follow-up, to avoid changing too many things here.
slices.add(new BytesArray(randomByteArrayOfLength(sliceLen))); | ||
remaining -= sliceLen; | ||
} | ||
return CompositeBytesReference.of(slices.toArray(BytesReference[]::new)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should generate the other BytesReference
variants too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO this is enough - it means that we make #iterator()
yield a fairly random selection of slice sizes, which is where I suspect the most bugs lurk. We'll also occasionally return a BytesArray
in the case that there's only one slice.
if (bytesReference.length() == 0) { | ||
return 0L; | ||
} else if (bytesReference.length() == Long.BYTES) { | ||
try (var baos = new ByteArrayOutputStream(Long.BYTES)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we have some library functions to deal with this directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently not, or at least I couldn't find any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the clarifications 👍
Well this is frustrating. https://gradle-enterprise.elastic.co/s/jd6eqec3nbvfe looks like a related failure, but I've been running that test in a loop for ages without being able to reproduce it. |
I have been running this test in a loop for 20+ hours without another failure. I'm going to ignore it in the name of progress. |
Relates elastic#96019 Closes elastic#96162
Today the blob store register supports recording only a
long
, represented as an 8-byte blob. We need to store a little more data in the register, so this commit generalises things to work with aBytesReference
directly.