Skip to content

Wait for the failed message index when restoring deleted messages by range - #6113

Open
mauroservienti wants to merge 1 commit into
masterfrom
range-unarchive-wait-for-index
Open

mauroservienti wants to merge 1 commit into
masterfrom
range-unarchive-wait-for-index

Conversation

@mauroservienti

Copy link
Copy Markdown
Member

Problem

Restoring deleted messages by date range (PATCH /api/errors/{from}...{to}/unarchive) selects the messages through FailedMessageViewIndex with a patch-by-query that allows stale results. When a message was deleted shortly before the request, the index can still have it as unresolved. The patch then skips it, and the message stays deleted. The request returns 202 and the handler succeeds, so nothing reports that it was skipped.

The acceptance test When_deleted_messages_are_restored.Should_restore_a_deleted_selection_and_a_deleted_group hits this on the Windows RavenDB build. It deletes two messages, waits until loading them by id shows them as deleted, and restores the range in the same second. The restore finds nothing, and the test times out waiting for the messages to come back. It failed this way on #6099 and on the 6.22 backport of #6100.

Change

The patch in ErrorMessagesDataStore.UnArchiveMessagesByRange waits until the index is up to date, for up to 5 minutes, the same time limit the group archive and restore use for their index waits. RavenDB waits only for the changes made before the query, so ongoing ingestion does not keep it waiting. If the index is still stale after the time limit, RavenDB throws, the handler fails, and the message is retried through recoverability instead of being skipped.

Tests

New UnarchiveByRangeTests.Should_unarchive_a_message_archived_right_before_the_request. It stops FailedMessageViewIndex, deletes a message, starts the range restore, then starts the index again. Without the change, the restore returns no messages and the message stays archived. With it, the message is restored.

…range

The patch query allowed stale results. A message deleted right before the request was still in the index as unresolved, so the patch skipped it and the message stayed deleted without an error.
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.

1 participant