Skip to main content

Audit queue writer

The audit queue writer moves captured accesses from the capture queue into the append-only audit evidence store. It is the only drain of the queue: without it, capture carries on, the queue fills and the store stops growing.

At a glance​

Batch classMGCWardenAuditWriter
Menu itemMGCWardenAuditWriterMenuItem, label Audit queue writer
Menu pathSystem administration → Setup → Audit queue writer
Who may run itMGCWardenAuditAdministrationPriv (granted at Update) → MGCWardenAuditAdministrationDuty → Warden audit administrator (MGCWardenAuditAdministrator). The API operation MGCWardenBatchService.runAuditWriter is granted on the same privilege and re-checks the same menu item
Feature toggleNone. run() reads no feature toggle, so it drains whatever is queued whether Warden Auditor (MGCWardenAuditFeature) is on or off. The sensors that fill the queue are what that toggle gates
Company scopeInstallation-wide. MGCWardenAuditQueue and MGCWardenAuditEvent are both shared (SaveDataPerCompany = No), so one run in any company drains every company's captures. Each store row goes into the partition named by the queue row's Company
Scheduled by defaultNo. Nothing in the product creates a batch job for it
RecurrenceYou choose. No recurrence is stated in the code. The shipped health rule WRITERLAG alerts when the oldest unwritten capture is more than 900 seconds old (one dedup window), so a recurrence comfortably shorter than 15 minutes keeps that rule from firing in normal operation
Setup-gap rules watching itAuditWriterNotScheduled (code AUDITWRITER): no job of this class carries a recurrence in any company, while Warden Auditor is on with an Active register entry, or captured reads already wait in the queue. A recurrence in any company clears it. The health rules WRITERLAG, QUEUEDEPTH and DROPRATE watch its effect (see Audit sensor health monitor)
Run recordNone. The batch log carries one summary line
Overlap guardYes. MGCWardenBatchOverlapGuard::refuses runs first and refuses while another task of this class is executing in any company

Purpose and business justification​

Warden's read sensors never write to the evidence store themselves. A sensor runs inside the user's own transaction, so it only enqueues a compact row into MGCWardenAuditQueue and returns; it can never slow or block the read it observes. Something then has to turn queue rows into evidence. That is this batch.

It also applies the deduplication: a repeated capture of the same actor, record, form and event kind inside the dedup window is folded into one store row, with an occurrence count, instead of a new row per open.

The justification is stated on the audit administrator role itself: the writer is the only drain from MGCWardenAuditQueue into the store, and without it the queue fills, priority shedding begins discarding captures, and the store silently stops growing while every configuration screen still looks correct.

How and when it is triggered​

  • Scheduled. Open the menu item, set the batch options on the dialog and give the job a recurrence. There are no other dialog fields.
  • Run now. The same menu item run interactively. canRunInNewSession() returns true, so the platform may run it in a second session for the same user with a progress form.
  • API. MGCWardenBatchService.runAuditWriter runs run() synchronously in the caller's session, behind MGCWardenApiDispatch::canRun on the same menu item (see Warden batch framework).

Nothing else calls it. Capture does not trigger a drain.

Configuration and scheduling options​

The class has no dialog fields: pack() returns conNull(). It reads these parameters from Warden audit parameters (MGCWardenAuditParameters, one shared row):

ParameterFieldShipped defaultWhat the writer does with it
Dedup window (minutes)DedupWindowMinutes15Folds a repeated capture into the newest matching store row whose Last occurred is inside the window. 0 switches dedup off and stores every capture as its own row. The table refuses a value outside 0..1440
Alert recipientsAlertRecipientsblankSemicolon-separated user IDs that receive the in-client overflow alert. A token that is not a user is skipped
Queue capacityQueueCapacity100,000Not read by the writer. The sensors use it to decide when to shed captures by tier; the writer only counts the rows they marked as dropped

Defaults come from MGCWardenAuditParameters.defaultValues(). The full parameter list is in Configuration reference.

Choosing a recurrence. A longer interval lets the queue grow and lets the health rules fire: the writer lag passes 900 seconds, the depth passes 80,000 rows, and the sensors start shedding lower tiers before the cap is reached. A shorter interval costs one batch start per run; a run with nothing queued does almost nothing. The writer cannot overlap itself, so a recurrence shorter than one run's duration only produces refused runs.

What it does​

MGCWardenAuditQueue (Dropped = No, oldest first)
| one transaction per queue row
v
lock partition chain head --> find dedup target above the sealed frontier
| |
| none | found
v v
append new store row OccurrenceCount + 1, LastOccurred moved
\___________________ delete the queue row ___________________/
|
v
count overflow drops --> self-audit row, alert, Warning exception,
tally per tier and reason, delete dropped rows
  1. Overlap guard. MGCWardenBatchOverlapGuard::refuses(this, 'Warden audit writer', ...) runs before any queue row is read. If another task of this class is executing in any company, the run writes a warning, files one Warning execution exception per open cause, and returns. Nothing is lost: the rows stay queued for the running task and the next recurrence.
  2. Drain. while select queue order by EnqueuedDateTime asc where queue.Dropped == NoYes::No. Each row goes through processQueueRow in its own try block, so one bad row never stops the drain.
  3. Per row, one transaction (processQueueRow):
    • storeCapture runs first. When the dedup window is positive it takes the partition's sealing lock, MGCWardenAuditHashChain::lockChainHead(_queue.Company), and then asks dedupTarget for the newest store row with the same partition, actor, record key, form and event kind, Last occurred inside the window, and a sequence number above the newest anchor's ToSequence.
    • Fold. If a target exists, OccurrenceCount goes up by one and LastOccurred moves forward. This is the one sanctioned update of a store row: it bypasses the append-only update() guard with skipDataMethods(true) and doUpdate(). If the target and the capture carry different retention classes, the row's RetentionClassId is blanked, which holds the row to the longest configured class.
    • Append. Otherwise MGCWardenAuditWriter::appendStoreRow allocates the partition's next sequence number and inserts a new MGCWardenAuditEvent row, with the retention class the sensor stamped at capture time and the SensorCapture detail template.
    • The queue row is then re-read and deleted in the same transaction.
  4. Overflow drops. After the drain the writer counts queue rows with Dropped = Yes and DropReason = Overflow. If there are any, it:
    • writes a QueueOverflowDrops self-audit store row (MGCWardenAuditSelfAudit::record);
    • sends an in-client alert (EventInbox, pop-up, no email) to each AlertRecipients user (alertOverflowDrops);
    • files a Warning execution exception;
    • writes one MGCWardenAuditDropTally row per tier and drop reason (tallyDrops), which is what the DROPRATE health rule measures once the rows are gone;
    • deletes every dropped queue row in one transaction.
  5. Writes the summary line: rows stored, failures, overflow drops.

Transaction boundaries. One transaction per queue row; the tally is one transaction; the delete of dropped rows is one transaction. There is no transaction around the whole run.

Why the sealing lock. A fold moves LastOccurred, and LastOccurred is one of the hashed columns. A fold into a row an anchor had already sealed would change a sealed digest, and every later verification would report tampering that never happened. The writer and the anchoring step of the integrity batch both take lockChainHead first, so whichever comes second sees what the first committed. A capture whose repeat is already sealed starts a new row.

Identity. appendStoreRow writes the store row's Actor through MGCWardenIdentityVault::toRef, so a store row written since D11 phase 2b names the actor by subject reference. The queue keeps the clear user ID while the row waits. dedupTarget matches both forms so a capture still folds into a row written before the cutover.

Concurrency and idempotency. The writer claims nothing: it reads queue rows without a lock and stores the capture before it learns whether the queue row is still there to delete. Two writers at once could store one capture twice. The overlap guard is what prevents that for batch tasks. It cannot see an interactive Run now or an API call, which are not batch tasks; run those one at a time.

Dependencies and prerequisites​

  • Active Sensitivity Register entries and the Warden Auditor feature switched on, or nothing is queued. The writer itself does not need either.
  • The identity vault must be able to issue references (appendStoreRow calls toRef). A vault failure fails that row, which stays queued.
  • AlertRecipients filled with user IDs if anybody is to be told about overflow drops.

Inputs and outputs​

DirectionTable or objectWhat
ReadsMGCWardenAuditQueueUndropped rows, oldest first; then dropped rows for the count and tally
ReadsMGCWardenAuditParametersDedupWindowMinutes, AlertRecipients
Reads, locksMGCWardenAuditHashAnchorThe partition's newest anchor, under pessimisticlock, when dedup is on
Reads, insertsMGCWardenIdentityVaultThrough toRef and existingRef
Inserts, updatesMGCWardenAuditEvent, MGCWardenAuditDetailParamNew store rows with their structured detail; the fold
DeletesMGCWardenAuditQueueEach stored row; then every dropped row after the tally
InsertsMGCWardenAuditDropTallyOne row per tier and drop reason when there were overflow drops
InsertsEventInboxThe overflow alert, one row per resolving recipient
InsertsMGCWardenExecutionExceptionOne Error per failed row; one Warning per run with overflow drops

No business event and no governance event-log row.

Logging and monitoring​

  • Batch history: the line Warden audit writer: N rows stored, N failures, N overflow drops.
  • Audit capture queue (System administration → Setup → Audit capture queue) shows what is waiting and what was dropped.
  • Audit sensor health (on the Warden Audit workspace) shows the three shipped rules: WRITERLAG (writer more than 900 s behind, Warning), QUEUEDEPTH (more than 80,000 rows waiting, Warning) and DROPRATE (any capture dropped in the last 60 minutes, Error). They are evaluated only when the audit health monitor runs; see Audit sensor health monitor.
  • Execution exceptions (System administration → Setup → Execution exceptions): failed rows and overflow warnings.
  • Audit store: a QueueOverflowDrops self-audit row per run that counted drops.
  • Setup gaps: AuditWriterNotScheduled when the writer has no recurrence in any company while capture is in use or reads wait; the row counts the waiting reads. The QueueCapacityUnlimited rule fires when QueueCapacity is 0, which switches the shedding ladder off. It is about the sensors' cap, not the writer's schedule.

Errors, recovery and troubleshooting​

SymptomCause and recovery
Error exception Warden audit writer failed to store queue row N (form F, actor A)That row's transaction rolled back; the row stays queued and the next run tries it again. The actor is shown by reference, or the text says the person has no reference yet and points at the queue row. There is no Retry handler on this exception; the next run is the retry
Warning exception N audit capture rows dropped on queue overflowThe sensors shed captures because the queue was over a tier's watermark. Run the writer more often or raise QueueCapacity. The drops are already counted; they cannot be recovered
Warning exception from the overlap guardTwo writer tasks overlap. Remove the duplicate job or lengthen the recurrence, then resolve the row
Queue keeps growing and no exception appearsThe writer is not scheduled. The setup gaps page shows AuditWriterNotScheduled; schedule it and run the audit health monitor to see the rules clear

The batch framework does not retry a failed task by itself: the class does not implement BatchRetryable, and BatchRun::isBatchRetryable defaults to false. Every per-row failure is caught. The overflow block after the drain has no catch of its own around the delete of dropped rows, so a failure there ends the task with an error and leaves the dropped rows in the queue; the next run then counts, alerts and tallies them again.

Impact on other functionality​

  • Unscheduled writer: captures accumulate, the sensors shed by tier, and the store, the timeline and every evidence pack show nothing for the period. The setup gaps page says so (AuditWriterNotScheduled).
  • Hash chain: the integrity batch can only anchor rows the writer has appended. A fold never lands in a sealed row, so the writer cannot break a published anchor.
  • Purge: a row the writer folds into is above the sealed frontier, and the purge never deletes an unanchored row, so the two never touch the same row.
  • Retention: the drop tally is operational telemetry; Warden retention cleanup removes it on the operational window.