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 class | MGCWardenAuditWriter |
| Menu item | MGCWardenAuditWriterMenuItem, label Audit queue writer |
| Menu path | System administration → Setup → Audit queue writer |
| Who may run it | MGCWardenAuditAdministrationPriv (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 toggle | None. 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 scope | Installation-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 default | No. Nothing in the product creates a batch job for it |
| Recurrence | You 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 it | AuditWriterNotScheduled (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 record | None. The batch log carries one summary line |
| Overlap guard | Yes. 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.runAuditWriterrunsrun()synchronously in the caller's session, behindMGCWardenApiDispatch::canRunon 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):
| Parameter | Field | Shipped default | What the writer does with it |
|---|---|---|---|
| Dedup window (minutes) | DedupWindowMinutes | 15 | Folds 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 recipients | AlertRecipients | blank | Semicolon-separated user IDs that receive the in-client overflow alert. A token that is not a user is skipped |
| Queue capacity | QueueCapacity | 100,000 | Not 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
- 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. - Drain.
while select queue order by EnqueuedDateTime asc where queue.Dropped == NoYes::No. Each row goes throughprocessQueueRowin its own try block, so one bad row never stops the drain. - Per row, one transaction (
processQueueRow):storeCaptureruns first. When the dedup window is positive it takes the partition's sealing lock,MGCWardenAuditHashChain::lockChainHead(_queue.Company), and then asksdedupTargetfor 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'sToSequence.- Fold. If a target exists,
OccurrenceCountgoes up by one andLastOccurredmoves forward. This is the one sanctioned update of a store row: it bypasses the append-onlyupdate()guard withskipDataMethods(true)anddoUpdate(). If the target and the capture carry different retention classes, the row'sRetentionClassIdis blanked, which holds the row to the longest configured class. - Append. Otherwise
MGCWardenAuditWriter::appendStoreRowallocates the partition's next sequence number and inserts a newMGCWardenAuditEventrow, with the retention class the sensor stamped at capture time and theSensorCapturedetail template. - The queue row is then re-read and deleted in the same transaction.
- Overflow drops. After the drain the writer counts queue rows with
Dropped = YesandDropReason = Overflow. If there are any, it:- writes a
QueueOverflowDropsself-audit store row (MGCWardenAuditSelfAudit::record); - sends an in-client alert (
EventInbox, pop-up, no email) to eachAlertRecipientsuser (alertOverflowDrops); - files a Warning execution exception;
- writes one
MGCWardenAuditDropTallyrow per tier and drop reason (tallyDrops), which is what theDROPRATEhealth rule measures once the rows are gone; - deletes every dropped queue row in one transaction.
- writes a
- 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 (
appendStoreRowcallstoRef). A vault failure fails that row, which stays queued. AlertRecipientsfilled with user IDs if anybody is to be told about overflow drops.
Inputs and outputs
| Direction | Table or object | What |
|---|---|---|
| Reads | MGCWardenAuditQueue | Undropped rows, oldest first; then dropped rows for the count and tally |
| Reads | MGCWardenAuditParameters | DedupWindowMinutes, AlertRecipients |
| Reads, locks | MGCWardenAuditHashAnchor | The partition's newest anchor, under pessimisticlock, when dedup is on |
| Reads, inserts | MGCWardenIdentityVault | Through toRef and existingRef |
| Inserts, updates | MGCWardenAuditEvent, MGCWardenAuditDetailParam | New store rows with their structured detail; the fold |
| Deletes | MGCWardenAuditQueue | Each stored row; then every dropped row after the tally |
| Inserts | MGCWardenAuditDropTally | One row per tier and drop reason when there were overflow drops |
| Inserts | EventInbox | The overflow alert, one row per resolving recipient |
| Inserts | MGCWardenExecutionException | One 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) andDROPRATE(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
QueueOverflowDropsself-audit row per run that counted drops. - Setup gaps:
AuditWriterNotScheduledwhen the writer has no recurrence in any company while capture is in use or reads wait; the row counts the waiting reads. TheQueueCapacityUnlimitedrule fires whenQueueCapacityis 0, which switches the shedding ladder off. It is about the sensors' cap, not the writer's schedule.
Errors, recovery and troubleshooting
| Symptom | Cause 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 overflow | The 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 guard | Two writer tasks overlap. Remove the duplicate job or lengthen the recurrence, then resolve the row |
| Queue keeps growing and no exception appears | The 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.
Related documentation
- Audit administrator
- Audit chain integrity: anchoring, publication and verification, Audit sensor health monitor
- Warden batch framework for the overlap guard, the batch API and company scope
- Configuration reference, Security model