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

s192 - Perform retries on runTask/updateTask #33

Merged
merged 2 commits into from
Jan 31, 2025
Merged

Conversation

jlorper
Copy link
Member

@jlorper jlorper commented Jan 31, 2025

Fixes

javax.servlet.ServletException: com.google.cloud.datastore.DatastoreException: Optimstic transaction was aborted
Try to better control places were commits are done and apply retries if needed.

Change implications

  • breaking change to API? no
  • changes dependencies? no

@jlorper jlorper requested a review from eschultink January 31, 2025 22:05
lockAcquisition.commit();

// actual task execution
runAndUpdateTask(jobState.getShardedJobId(), taskId, sequenceNumber, jobState, taskState);
Copy link
Member Author

Choose a reason for hiding this comment

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

I think this was triggering the DatastoreException, not being caught, so reaching the servlet execution

ShardRetryState<T> retryState = null;
Transaction postRunUpdate = null; //txn limited to 60s, so can't open this before run() call

RetryType retryType = RetryType.NONE;
Copy link
Member Author

Choose a reason for hiding this comment

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

reorganized the code, so all the handle failures happens at the end, and with retries

} catch (Throwable ex) {
postRunUpdate = getDatastore().newTransaction();
t = ex;
retryType = RetryType.SLICE; // this was originally shard, but seems like a mistake
Copy link
Member Author

Choose a reason for hiding this comment

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

Note this change:

  • message (slice error) and action (shard failure) were inconsistent
  • probably makes sense to handle it as slice failure rather than prematurely kill the shard?

}
rollbackIfActive(postRunUpdate);
RetryExecutor.call(FOREVER_RETRYER, () -> {
Copy link
Member Author

Choose a reason for hiding this comment

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

in the finally, perform the handle error (if any) + update task

@jlorper jlorper merged commit 6e49154 into main Jan 31, 2025
3 checks passed
@jlorper jlorper deleted the s192-more-retries branch January 31, 2025 22:45
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