Skip to content
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

Improve configuration around readAfterReplicaAcknowledged() to allow a configurable number of inflight messages. #1564

Closed
RobAustin opened this issue Apr 22, 2024 · 1 comment
Assignees

Comments

@RobAustin
Copy link
Member

RobAustin commented Apr 22, 2024

Relates to #1566 and https://github.com/ChronicleEnterprise/Chronicle-Queue-Enterprise/pull/704

Improve configuration around readAfterReplicaAcknowledged() which can be used with replication to allow a configurable number of inflight messages.

image image image

The charts above shows the difference allowing inflight messages makes.

API CHANGE

we added the following

/**
     * Allows you to control the number of in flight messages that are allowed when setting {@code acknowledgedIndexReplicatedCheck},  By default, this is set to:
     * <p>
     * <p>
     * By providing a custom implementation of {@code acknowledgedIndexReplicatedCheck} you can control the number of in-flight messages that are allowed before the message is available to be read by the tailer.
     * And in addition, then acknowledgedIndexReplicatedCheck will be set to true.
     * <p>
     * below is the default implementation:
     * <pre>
     * boolean acknowledgedIndexReplicatedCheck(long index, long lastSequenceAck) {
     *      return index == lastSequenceAck;
     * }
     * </pre>
     * <p>
     * With this default implementation it will ensure tailer will not be able to read a message until it has been acknowledged that it has been full replicated.
     * <p>
     * However, if you wish to tolerate a number of in-flight or pending messages before the message.,
     * You can set this to a different implementation. For example, if you wish to tolerate one unacknowledged message, set {@code tolerateNumberOfUnAckedMessages} to 1, as shown below:
     * <pre>
     * boolean acknowledgedIndexReplicatedCheck(long index, long lastSequenceAck) {
     *     int tolerateNumberOfUnAckedMessages = 1;
     *     return index <= lastSequenceAck + tolerateNumberOfUnAckedMessages;
     * }
     * </pre>
     *
     * @param acknowledgedIndexReplicatedCheck as a custom implementation of {@code acknowledgedIndexReplicatedCheck}
     */
    default void acknowledgedIndexReplicatedCheck(AcknowledgedIndexReplicatedCheck acknowledgedIndexReplicatedCheck) {
        throw new UnsupportedOperationException("This method is not supported by this implementation");
    }

For a benchmark of this please see at https://github.com/ChronicleEnterprise/Chronicle-Queue-Enterprise/pull/704/files#diff-c099f655dcf641932ba5a714623534c6d2165d5f6a49619cd9dce61fc2e6ad96

@RobAustin RobAustin self-assigned this Apr 22, 2024
RobAustin pushed a commit that referenced this issue Apr 22, 2024
…allow a configurable number of in-flight messages.
RobAustin added a commit that referenced this issue Apr 25, 2024
)

* #1564 Improve configuration around readAfterReplicaAcknowledged() to allow a configurable number of in-flight messages.

* removed unwanted test

* reverted back to private

* added another test

* moved the tests

* added javadoc

* added @NotNull to  acknowledgedIndexReplicatedCheck

---------

Co-authored-by: Rob Austin <rob.austin@boundedbuffer.co.uk>
@hft-team-city
Copy link
Collaborator

Released in Chronicle-Queue-5.25ea15, BOM-2.25ea52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants