Skip to content

Add deterministic ids to failed message imports - #5919

Merged
rbev merged 1 commit into
masterfrom
audit-deterministic-ids
Sep 25, 2026
Merged

rbev merged 1 commit into
masterfrom
audit-deterministic-ids

Conversation

@rbev

@rbev rbev commented Sep 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Derive failed Audit import keys from the message's unique ID, falling back to a deterministic key from the native transport ID when headers are malformed or incomplete. Repeated failures now use the same document and log-file name.
  • Store the RavenDB collection prefix only in the RavenDB persister and replace existing entries by key in the InMemory persister.
  • Add shared deduplication and key-derivation tests that run against both persisters.

Error-instance precedent

Verification

  • Audit persistence test projects (InMemory and RavenDB): FailedAuditStorageTests — 6 passed in each.
  • ServiceControl.Audit build passed.

@rbev
rbev added this pull request to stack #5920 September 24, 2026 06:42
@rbev rbev changed the title [Audit Ingestion 2] Add deterministic ids to failed message imports [SQL Audit Ingestion 2] Add deterministic ids to failed message imports Sep 24, 2026
public async Task SaveFailedAuditImport(FailedAuditImport message, CancellationToken cancellationToken = default)
{
using var session = await sessionProvider.OpenSession(cancellationToken: cancellationToken);
if (message.Id != null && !message.Id.StartsWith("FailedAuditImports/", StringComparison.OrdinalIgnoreCase))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is strange. Why would an ID ever include the "FailedAuditImports/" prefix at all when it reaches this method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The code is replicating what we were doing in error, where there are places that records get roundtripped.
In this case I'm pretty sure it's always unset on the way in.

I did wonder whether it would be better to either:

  • Verify that and enforce it being unset on save; or
  • Check if the "id" is even used outside of raven and remove it from the contract (I think we did this in at least one place)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From our discussion, this is how the error instance does it and it can stay.
It has to be returned for now so deletions work

@johnsimons johnsimons left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, but there is a question that i don't understand

Base automatically changed from rhys/audit-seam-review to master September 25, 2026 05:54
@rbev
rbev force-pushed the audit-deterministic-ids branch from 8428c7c to d045c8e Compare September 25, 2026 05:54
@rbev
rbev marked this pull request as ready for review September 25, 2026 05:55
@rbev rbev changed the title [SQL Audit Ingestion 2] Add deterministic ids to failed message imports Add deterministic ids to failed message imports Sep 25, 2026
@rbev
rbev merged commit 99863ab into master Sep 25, 2026
36 checks passed
@rbev
rbev deleted the audit-deterministic-ids branch September 25, 2026 06:25
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