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

Add FindTailAttr for configurable find_tail behavior #2781

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

muhamadazmy
Copy link
Contributor

@muhamadazmy muhamadazmy commented Feb 25, 2025

Add FindTailAttr for configurable find_tail behavior

Summary:
FindTailAttr allows find_tail users to adjust durability and accuracy. Currently, two modes are supported:

Approximate: A fast check that usually returns immediately with the last known tail.
Durable (default): Ensures a reliable tail find.

Loglet implementations can choose to always run Durable find_tail.


Stack created with Sapling. Best reviewed with ReviewStack.

@muhamadazmy muhamadazmy force-pushed the pr2781 branch 3 times, most recently from 15a86c4 to ab3d293 Compare February 25, 2025 15:36
@muhamadazmy muhamadazmy changed the title WIP: Introduce FindTailAttr Add FindTailAttr for configurable find_tail behavior Feb 25, 2025
@muhamadazmy muhamadazmy marked this pull request as ready for review February 25, 2025 15:47
Copy link
Contributor

@AhmedSoliman AhmedSoliman left a comment

Choose a reason for hiding this comment

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

Thank you for working on this. I've left a couple of naming/description suggestions. Please consider them.

Comment on lines 158 to 160
/// Finds the durable tail of the loglet.
#[default]
Durable,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest we call this "ConsistentRead" all find-tail operations will find the durable tail, but Consistent performs a consistent-read instead.

@@ -150,6 +153,17 @@ pub trait Loglet: Send + Sync {
async fn seal(&self) -> Result<(), OperationError>;
}

#[derive(Default, Clone, Copy, PartialEq, Eq)]
pub enum FindTailAttr {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can this be FindTailOpts or FindTailOptions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The reason I have chosen this name over FindTailOptions is that it conflicts with another FindTailOptions enum defined internally in replicated_loglet. But maybe we can change the other one instead

/// Approximate find tail of the loglet. This should cheap to run based on the
/// loglet implementation. If an efficient approximation is not possible, it must
/// fall back to a durable check.
Approximate,
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps Fast reflects better on what is means.

Comment on lines 161 to 163
/// Approximate find tail of the loglet. This should cheap to run based on the
/// loglet implementation. If an efficient approximation is not possible, it must
/// fall back to a durable check.
Copy link
Contributor

Choose a reason for hiding this comment

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

I might have mislead you by suggesting approx as a good name. Instead, I think explaining this in terms of the fact we might be returning a stale value of the tail is better. The enum variant can be StaleAllowed or Fast

@muhamadazmy muhamadazmy force-pushed the pr2781 branch 4 times, most recently from 14a42e3 to 8c5ecbe Compare March 3, 2025 14:59
Summary:
FindTailAttr allows find_tail users to adjust durability and accuracy. Currently, two modes are supported:

Approximate: A fast check that usually returns immediately with the last known tail.
Durable (default): Ensures a reliable tail find.

Loglet implementations can choose to always run Durable find_tail.
@muhamadazmy
Copy link
Contributor Author

Thanks @AhmedSoliman for your review as usual. I considered and applied all your comments. I still had to rename the FindTailOptions defined under the replicated loglet to FindTailFlags that is different from the public FindTailOptions. I am still not happy with the name, but wasn't sure which one fits the best. I also changed the visibility scope to crate.

Other options could be:

  • ReplicatedFindTailOptions or InnerFindTailOptions but I find it misleading.
  • TailSearchOptions but completely wrong terminology

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

Successfully merging this pull request may close these issues.

2 participants