Skip to content

Commit

Permalink
Ensure Master Monitor Can Read Lock ByteBuffer More than Once (#686)
Browse files Browse the repository at this point in the history
It is possible that the DynamoDBMasterMonitor checks for the current
leader more often than the underlying ByteBuffer is updated by
the DynamoDB library.  In this case, we should rewind the buffer.

We can also optionally create a separate config for the lock client
update and the monitor check leader interval to ensure check leader
is called less frequently than the lock client updates.
  • Loading branch information
kmg-stripe authored Jul 9, 2024
1 parent 2c5bfd4 commit e11c26d
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ private void updateLeader(@Nullable MasterDescription nextDescription) {
}

private MasterDescription bytesToMaster(ByteBuffer data) {
// It is possible that the underlying buffer is read more than once,
// so if the offset of the buffer is at the end, rewind, so we can read it.
if (!data.hasRemaining()) {
data.rewind();
}
final byte[] bytes = new byte[data.remaining()];
data.get(bytes);
try {
Expand Down

0 comments on commit e11c26d

Please sign in to comment.