Skip to content

Add IsSystemMessage to the audit TimeSent indexes - #6241

Open
warwickschroeder wants to merge 2 commits into
masterfrom
6240-sql-server-audit-persistence-messag
Open

warwickschroeder wants to merge 2 commits into
masterfrom
6240-sql-server-audit-persistence-messag

Conversation

@warwickschroeder

Copy link
Copy Markdown
Contributor

What this fixes

Part of #6240 (queries 2, 3 and 4). All Messages and an endpoint's message list hide system messages by default, and no index held IsSystemMessage, so their capped Total-Count read every candidate row. The per-day audit count had the same gap. On an IO-limited database with a few hundred thousand rows, these counts reached the 60-second query limit, and ServicePulse showed the page without the audit messages. On 200,000 seeded rows, all three counts now read only an index, and the totals stay the same.

  • IX_AuditMessages_TimeSent includes IsSystemMessage. All Messages count: 152,977 reads down to about 440.
  • IX_AuditMessages_ReceivingEndpointName_TimeSent includes IsSystemMessage and ProcessedAt. One endpoint's count and its per-day audit count: 42,601 reads down to 83 each.
  • One migration per provider drops and recreates both indexes during setup, with the same names and keys.
  • On PostgreSQL only the endpoint count gets faster (4,660 buffers down to 130). PostgreSQL stores long headers outside the main table, so the other two counts were already cheap there.

Tests

  • ServiceControl.Audit.Persistence.Tests.SqlServer (new SystemMessageCountReadsTests): the All Messages and endpoint counts stay under 1,000 reads, and a quiet endpoint's message and per-day counts stay under 10, each with the right total. Each test failed when the include it pins was removed.
  • SlowMigrationOperationApprovals for SQL Server and PostgreSQL: approve the drop and recreate of both indexes.

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