Skip to content

Use readExplicitLAC instead of readEntry in order to get current LastAddConfirmed#1572

Closed
eolivelli wants to merge 6 commits into
apache:masterfrom
eolivelli:fix/explicitlac-reader
Closed

Use readExplicitLAC instead of readEntry in order to get current LastAddConfirmed#1572
eolivelli wants to merge 6 commits into
apache:masterfrom
eolivelli:fix/explicitlac-reader

Conversation

@eolivelli

@eolivelli eolivelli commented Jul 30, 2018

Copy link
Copy Markdown
Contributor

Motivation

Readers have to explicitly call readExplicitLastConfirmed in order to leverage ExplicitLAC.
I would like to have a unified way to read LastAddConfirmed.

Changes

This change makes the client use internally readExplicitLastConfirmed instead of using readLastAddConfirmed.
We need to introduce something similar to tryReadLastAddConfirmed in order to make it consistent with readLastAddConfirmed.

It lacks support for Long Poll Reads, notably we would have to listen on ExplicitLAC modifications on the bookie side in order to wake up the readers even in case of setExplicitLAC from the writer and we would need to change protocol for readLastAddConfirmedAndEntry in order to return the ExplicitLAC.

We cannot support v2 clients.

@eolivelli eolivelli requested a review from sijie July 30, 2018 11:27
@eolivelli eolivelli force-pushed the fix/explicitlac-reader branch from 5918517 to 5f5ed5c Compare July 30, 2018 11:29
@eolivelli eolivelli requested a review from jvrao July 31, 2018 08:27
@eolivelli

Copy link
Copy Markdown
Contributor Author

@sijie @jvrao can you take a look to this idea?

1 similar comment
@eolivelli

Copy link
Copy Markdown
Contributor Author

@sijie @jvrao can you take a look to this idea?

@sijie

sijie commented Aug 22, 2018

Copy link
Copy Markdown
Member

@eolivelli sorry I missed your comment. I typically ignore any WIP PRs...

@sijie sijie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the approach seems to be okay to me.

one general comment: why it is only applied to asyncTryReadLastConfirmed?

};

new ReadLastConfirmedOp(this, innercb).initiate();
asyncReadExplicitLastConfirmed(cb, ctx);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sijie here I am changing also asyncReadLastConfirmed

This is actually the core of the change.
I had to re implement asyncTryReadLastConfirmed because there is no existing support for explicitLAC

@eolivelli eolivelli force-pushed the fix/explicitlac-reader branch from 42b5a25 to 0872243 Compare December 28, 2018 08:35
@eolivelli eolivelli changed the title WIP - Use readExplicitLAC instead of readEntry in order to get current LastAddConfirmed Use readExplicitLAC instead of readEntry in order to get current LastAddConfirmed Dec 28, 2018
@eolivelli

eolivelli commented Dec 28, 2018

Copy link
Copy Markdown
Contributor Author

@sijie @jvrao @ivankelly I have rebased this patch onto current master.
I would like to insert it in 4.9.

I only have to add unit tests. All current tests about readLastAddConfirmed() and tryReadLastAddConfirmed() are passing even by enabling the feature by default.
So I only have to find interesting tests and transform them to a parametrized version which run the test with/without this new feature.

}
}

private void asyncReadLastConfirmedInternal(final ReadLastConfirmedCallback cb, final Object ctx) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

asyncReadLastConfirmedInternal is a bad name. I would prefer calling it asyncReadPiggybackLastConfirmed (in contrast to asyncReadExplicitLastConfirmed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

*/

public void asyncReadLastConfirmed(final ReadLastConfirmedCallback cb, final Object ctx) {
if (clientCtx.getConf().useExplicitLacForReads) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure using a flag is the best choice here. the bookkeeper client should be smart to figure out whether it should be reading explicit lac or piggybacked lac.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe the name is misleading but it is already here.
This function will compose explicit and piggybacked LAC.
So actually it would be better to use always readExplicitLAC RPC, but we cannot enable it by default because it works only with recent bookies and with v3 protocol

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Client knows it is using V3 protocol or not; so why not use the explicitLAC for >= v3 automatically without a conf option?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ExplicitLAC is since 4.5. V3 protocol was already present. So we have bookies which talk v3 and do not know ExplicitLAC protocol: we will break compatibility from 4.9 clients and 4.4 bookies.
Honestly I don't think this is a real production problem because 4.4 is very old, but we don't have a clear EOL policy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli I don't understand your comment here. if a bookie doesn't know ExplicitLAC, the request will be rejected and the client will know about that, right? when client know that, it can fallback to disable using explicit lac, no?

@eolivelli eolivelli Jan 8, 2019

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sijie so you are suggesting to fallback to piggybackLac in case of "UnsupportedOperation" error from bookie.
We should keep track of this per-bookie. I think this is very tricky, we need to add a lot of code and runtime overhead for the sake of compatibility with very old bookies (4.4).

We can have this configuration flag, enabled by default in 4.9 in case of v3+ protocol and disable for v2 protocol, and then drop it as soon as we decide to drop support for compatibility with such old versions.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli

you are suggesting to fallback to piggybackLac in case of "UnupportedOperation" error from bookie.

yes.

We should keep track of this per-bookie.

probably yes.

We can have this configuration flag, enabled by default in 4.9 in case of v3+ protocol and disable for v2 protocol,

my main concern is with this change, we have so many different variants of reading lac operations in the main repo. it is very confusing and hard to maintain. I would suggest us holding on merging this PR and thinking of a better solution for it, rather than rushing at merging this and make things hard to maintain in future.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sijie I see your concern. There is no hurry, we can work on this topic for 4.10.
I think that current asyncReadExplicitLastConfirmed() is better because it is actually merging the two values (piggy backed + explicit)

if (lastEntryBuffer != null && lastEntryBuffer.readableBytes() > 0) {

I think this is the future, I am not dropping the legacy method only for compatibility with 4.4.

The best would be to not have the flag, not perform any compatibility effort, and say that 4.9 clients are able to read from 4.4 bookies only using v2 protocol (in v2 protocol we don't have ExplicitLAC so we cannot use PendingReadLacOp)

PendingReadLacOp is already here, I am not adding it, I am only suggesting to use PendingReadLacOp for regular readLastAddConfirmed() instead of ReadLastConfirmedOp.

Ideally we should merge PendingReadLacOp with ReadLastConfirmedOp and drop PendingReadLacOp, but it is greater work, because ReadLastConfirmedOp handles fencing stuff

// Extract lac from last entry on the disk
if (lastEntryBuffer != null && lastEntryBuffer.readableBytes() > 0) {
RecoveryData recoveryData = lh.macManager.verifyDigestAndReturnLastConfirmed(lastEntryBuffer);
long recoveredLac = recoveryData.getLastAddConfirmed();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't it called piggyBackedLAC?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to newLac, it is clearer, thanks


/**
* This op is try to read last confirmed without involving quorum coverage checking.
* Use {@link PendingLacOp} if you need quorum coverage checking.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean PendingReadLacOp?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if we ever need quorum for LAC. LAC means it has quorum, so we can take greatest LAC.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we take out the coverageSet.checkCovered() check from PendingReadLacOp, then we don't need this right? I don't know why we have the quorum check in there, What scenario needs LAC to be quorum checked? @sijie ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't looked at this patch, but this coverage check is there because fencing is piggybacked on the LAC read.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvrao @ivankelly @sijie
This feature has the same semantics as TryReadLastConfirmedOp:

TryPendingReadLacOp -> PendingReadLacOp
TryReadLastConfirmedOp -> ReadLastConfirmedOp

We are trying to advance LAC and return as soon as we have an useful value, without full coverage checks.

AFAIK This feature is a used for Long-Poll reads, which I am not going to implement soon, at least not within 4.9 timeline.
In Long Poll reads tests I have found this API asyncTryReadLastConfirmed and for consistency I have created a similar one for ExplicitLAC based reads.

@jvrao jvrao Jan 3, 2019

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without full coverage checks.

This is what I am trying to understand. Once we have LAC updated (either piggy-back or explicit) it means that it has met Write Quorum. So I don't understand what is the additional coverage check needed. This is not a fencing read or reading beyond LAC, this operation reads LAC which must have been updated by the writer after write quorum, hence it is persisted. If we need latest LAC we need quorum (for fencing) but for reads, you don't need.

RecoveryData recoveryData = lh.macManager.verifyDigestAndReturnLastConfirmed(lastEntryBuffer);
long recoveredLac = recoveryData.getLastAddConfirmed();
if (recoveredLac > maxLac) {
newLac = recoveredLac;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are overwriting newLac.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@eolivelli

Copy link
Copy Markdown
Contributor Author

For what is worth...
I am testing this patch with some projects and it works like a charm, on the writers you can enable ExplicitLAC and the readers are able to see the LAC advance without changing code (which is using readLastAddConfirmed and not readExplicitLastConfirmed).
No need to extra NOOP writes to make LAC advance, all is transparent.

I think this is a great step forward for BK usability

@eolivelli

Copy link
Copy Markdown
Contributor Author

Ping @sijie

@sijie sijie left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still don't understand why we can't merge explicit lac and piggybacked lac into one read operations. my concern is after this change, we ended up having many variants of reading last confirmed. what is your plan for that in long term?

*/

public void asyncReadLastConfirmed(final ReadLastConfirmedCallback cb, final Object ctx) {
if (clientCtx.getConf().useExplicitLacForReads) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eolivelli I don't understand your comment here. if a bookie doesn't know ExplicitLAC, the request will be rejected and the client will know about that, right? when client know that, it can fallback to disable using explicit lac, no?

if (clientCtx.getConf().useExplicitLacForReads) {
asyncTryReadExplicitLastConfirmed(cb, ctx);
} else {
asyncTryReadLastConfirmedInternal(cb, ctx);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the name here is not consistent with asyncReadPiggybackLastConfirmed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sijie I missed to renamed this method as well.
done

@eolivelli

Copy link
Copy Markdown
Contributor Author

@sijie @jvrao @ivankelly
I am closing this one in favour of #1901 which is simpler and does not introduce new variants of read LAC.
We will deal with tryReadLastAddConfirmed in the future.
To me it is important to enable new API users to use ExplicitLAC

@eolivelli eolivelli closed this Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants