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

Makes seeding a fate transaction more efficient #5122

Merged
merged 8 commits into from
Dec 10, 2024

Conversation

keith-turner
Copy link
Contributor

Modified fate to seed fate transaction in single conditional mutation instead of multiple.

fixes #5097

Modified fate to seed fate transaction in single conditional mutation
instead of multiple.

fixes apache#5097
@keith-turner keith-turner added this to the 4.0.0 milestone Nov 28, 2024
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.

Most of my comments are trivial or just observations. Logic looks good and consistent with previous impl with the added improvement of a single condition mutation for seeding a USER transaction. Some small questions/potential concerns. Verified fate tests still pass. Also, I have not looked through all of the FateStoreIT changes yet.

// signal to the super class that a new fate transaction was seeded and is ready to run
seededTx();
return true;
} else if (status == FateMutator.Status.REJECTED) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering about the following case:
The first attempt is actually written but returns a status of UNKNOWN. Then, any subsequent attempts will return REJECTED causing seedTransaction to return that it failed/false.
This was something that was previously handled

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Looking over the way things works end to end if a lot of effort is made here to determine what happened with unknown then the calling code will not really care (because it just logs the result). However the way the functions are structured that is not obvious and if future calling code did something besides just logging the result then it would not be correct in this corner case. I will try to look at the end to end structure and clean this up to either handle that corner case or make the functions reflect a best effort impl.

Copy link
Contributor Author

@keith-turner keith-turner Dec 6, 2024

Choose a reason for hiding this comment

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

Looking at this some more I will make it try to determine what happened. Even thought its just logging, having accurate log message is important for debugging. And I like the info provided by the current log messages, so do not want to remove them.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried to handle the unknown case and realized its impossible to determine what happened in this case. Prior to these changes a reservation was acquired and that has unique uuid which can be used to determine if the reservation was acquired when unknown is seen. Now that this code is using a single conditional mutation, no reservation is required. The reservation is only required for updates that happen over multiple conditional mutations.

So since there is no way to know what happened, I adjusted the logging and code to reflect this in 89b70da

Copy link
Member

Choose a reason for hiding this comment

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

Ah, yeah you're right...
The new comment for the UNKNOWN case looks good. The new mention of "possibly unable to seed" in FateLogger looks good.

Comment on lines 53 to 68
* Seeds a transaction with the given repo if it does not exists. Will set the status to
* SUBMITTED. Will set the fate key. Will set autoCleanup if true. Will set the creation time.
*
* <p>
* In the case where a process dies in the middle of a call to this. If later, another call is
* made with the same key and its in the new state then the FateId for that key will be returned.
* </p>
* @return optional w/ the fate id set if seeded and empty optional otherwise
*/
Optional<FateId> seedTransaction(String txName, FateKey fateKey, Repo<T> repo,
boolean autoCleanUp);

/**
* Seeds a transaction with the given repo if its current status is NEW and it is currently
* unreserved. Will set the status to SUBMITTED. Will set autoCleanup if true. Will set the
* creation time.
*
* @throws IllegalStateException when there is an unexpected collision. This can occur if two key
* hash to the same FateId or if a random FateId already exists.
* @return true if seeded and false otherwise
*/
Optional<FateTxStore<T>> createAndReserve(FateKey fateKey);
boolean seedTransaction(String txName, FateId fateId, Repo<T> repo, boolean autoCleanUp);
Copy link
Member

Choose a reason for hiding this comment

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

Should also add that it will set the txName to these descriptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated in 7110fd7

Copy link
Member

@kevinrr888 kevinrr888 Dec 9, 2024

Choose a reason for hiding this comment

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

Looks good. I also like the new @ return description for these methods indicating result may not be entirely accurate in case of failure

txStore = store.reserve(fateId1);
try {
assertEquals(TStatus.IN_PROGRESS, txStore.getStatus());
txStore.forceDelete();
Copy link
Member

Choose a reason for hiding this comment

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

could also check top() here before deleting

txStore.setTransactionInfo(TxInfo.TX_NAME, txName);

txStore.setStatus(SUBMITTED);
return store.seedTransaction(txName, fateKey, repo, autoCleanUp);
Copy link
Member

Choose a reason for hiding this comment

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

I agree that FateKey contains the same info. Those changes look good.

// signal to the super class that a new fate transaction was seeded and is ready to run
seededTx();
return true;
} else if (status == FateMutator.Status.REJECTED) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, yeah you're right...
The new comment for the UNKNOWN case looks good. The new mention of "possibly unable to seed" in FateLogger looks good.

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.

These changes look good to me. I also looked through the FateStoreIT changes and those look good. I like the new testCreate and testConcurrent tests.

@keith-turner keith-turner merged commit 6407c31 into apache:main Dec 10, 2024
8 checks passed
@keith-turner keith-turner deleted the speed-up-seeding branch December 10, 2024 00:21
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.

Seeding compaction commit and split fate transactions is slow
2 participants