Skip to content

Make several TableOpsImpl methods atomic #5540

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

DomGarguilo
Copy link
Member

Fixes #5494
This PR replaces places were multiple calls to set or remove properties were being done with a single modify properties block to make things atomic. The affected methods are:

  • setSamplerConfiguration
  • clearSamplerConfiguration
  • setLocalityGroups

@DomGarguilo DomGarguilo added this to the 4.0.0 milestone May 8, 2025
@DomGarguilo DomGarguilo self-assigned this May 8, 2025
Copy link
Member

@kevinrr888 kevinrr888 left a comment

Choose a reason for hiding this comment

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

LGTM, code is also quite a bit more succinct now

}

@Override
public void clearSamplerConfiguration(String tableName)
throws AccumuloException, TableNotFoundException, AccumuloSecurityException {
throws AccumuloException, AccumuloSecurityException {
Copy link
Member

Choose a reason for hiding this comment

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

Why would this no longer throw TableNotFoundException? That seems odd.

Copy link
Member Author

Choose a reason for hiding this comment

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

Nothing in this method throws TableNotFoundException anymore I guess. In the old code, clearSamplerOptions() threw it when it called getProperties() but all of that has been replaced with the modifyProperties() block which does not throw TableNotFoundException.

Copy link
Member

Choose a reason for hiding this comment

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

I would expect modifyProperties to throw TableNotFoundException. At least, some error should happen if the table doesn't exist... I'm not sure what error that is. But, I think this PR should wait until we figure that out, because this changes the behavior, and we shouldn't change the API behavior for the case when the table doesn't exist.

Copy link
Member Author

Choose a reason for hiding this comment

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

So it turns out some of the TableOps methods wrap TableNotFoundException in AccumuloException. Created #5595 to add a bit of clarity for those methods. I am not sure why some methods do this. It seems like it would be better to just throw it directly (might avoid confusion like this scenario).

Anyways, I dont think this is a blocker for this PR.

@DomGarguilo
Copy link
Member Author

Why would this no longer throw TableNotFoundException? That seems odd.

@ctubbsii I added a new helper method, modifyPropertiesUnwrapped() which wraps modifyProperties() catches AccumuloException, and throws TableNotFoundException if thats its cause. I used this new helper method in only the methods that I changed here (setSamplerConfiguration, clearSamplerConfiguration, setLocalityGroups). This adds back the TableNotFoundException that had been removed by a previous change in this PR. It should also restore the exception handling functionality that was in place before converting these methods to use modifyProperties.

@DomGarguilo DomGarguilo requested a review from ctubbsii June 6, 2025 17:34
Copy link
Member

@ctubbsii ctubbsii left a comment

Choose a reason for hiding this comment

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

The strategy to re-throw a TNFE by unwrapping the exception wrapped in modifyProperties is okay, but the implementation is not working as intended, since you're looking up the table ID. After that is fixed, this could probably be merged.

However, this is still just a hack, because modifyProperties doesn't throw TNFE when it should. A possible better solution is to deprecate it, and create a replacement method, mutateProperties that has the correct exception throwing behavior. So, instead of adding more unwrapping... you remove some of the existing wrapping that is happening in the first place. This would actually go well with the parameter name, which is "mapMutator", which works better with a method named "mutate" rather than "modify".

The problem with creating a new method is that we tend to avoid doing that in bugfix releases, because it violates semver. However, the spirit of semver is to avoid breaking user code. Although this would add a new method, I think that the only code that would break is subclasses, but nobody else is likely to be subclassing the TableOperations interface. So, maybe it is tolerable to add this in a bugfix? If not, your strategy is fine for 2.1 We can fix it the way I'm suggesting in 4.0, and add a deprecation to the old method in a 3.1.

DomGarguilo and others added 2 commits June 9, 2025 11:11
@DomGarguilo
Copy link
Member Author

However, this is still just a hack

Yea, definitely a hack and should just exist temporarily until we properly fix things.

So, maybe it is tolerable to add this in a bugfix? If not, your strategy is fine for 2.1 We can fix it the way I'm suggesting in 4.0, and add a deprecation to the old method in a 3.1.

Right now the changes in this PR are made against 4.0. Are you suggesting that we make these changes against 2.1 too?

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.

Atomically update locality group properties.
4 participants