Skip to content

Idempotency Concern of the ProcessAppendQueueItem Function #164

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
NullPointer4096 opened this issue Apr 17, 2023 · 0 comments
Open

Idempotency Concern of the ProcessAppendQueueItem Function #164

NullPointer4096 opened this issue Apr 17, 2023 · 0 comments

Comments

@NullPointer4096
Copy link

I would like to kindly bring attention to a potential issue in the ProcessAppendQueueItem, which is invoked by messages that enter the %TableNamespace%-ingestion queue. For each queue item, function ProcessPasswordEntry is called to first increment the pwned passwords’ prevalence stored in the table entries and then increment the prevalence in the blob storage. However, this method is not idempotent. Suppose the function is crashed after incrementing table entries; when the function retries, the table entries and blob entries will be incremented again. The values stored in the table entries hence deviate from the blob entries and the ground truth. If the retry happens after incrementing both the table entries and the blob entries, both counters will deviate from the ground truth due to duplicate updates.

Though the deviation of the prevalence counter is not a huge problem, such an issue can be resolved by maintaining a LastRequestId field in each table entry and blob entry, which stores the invocation id of the last ProcessAppendQueueItem function call. The invocation id is constant across Azure Function retries. Before updating a table/blob entry, if the comparison finds item.LastRequestId == FunctionContext.InvocationId, this means the update has happened before, so continue to iterate the next table entry or blob. Otherwise, if item.LastRequestId != FunctionContext.InvocationId, update the prevalence counter and the LastRequestId field with FunctionContext.InvocationId.

Thank you for considering this potential issue. I hope this suggestion can help improve the idempotency of the ProcessAppendQueueItem. Please feel free to reach out if you have any questions or concerns.

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

No branches or pull requests

1 participant