Earmark retention cleanup
Earmark retention cleanup deletes Earmark's operational records once they are older than the day counts on Earmark parameters. It touches four kinds of record (timeline rows, closed execution exceptions, completed accrual events and price proposal sessions) and never a deal, an accrual, a balance or a claim. This page is for the administrators who schedule the job and check that it runs: the System administrator and the Accounting manager.
Runs: a batch job you schedule, or on demand from Earmark > Periodic tasks > Earmark retention cleanup. Nothing runs it by itself. Set up by: Accounting manager or System administrator. Watched by: System administrator.
Why it exists
Some Earmark tables grow with every posting and every act. The accrual event queue takes a row per accrual instance per posted document, the timeline takes a row per act, and the execution exceptions workbench keeps every failure it ever recorded. Without a cleanup these tables grow without limit, and the pages and queries over them slow down.
None of these rows is the permanent record of anything. A posted accrual event points at the accrual transaction it produced, a resolved exception is finished work, and the governed records (deals, accruals, balances, claims) keep their own history. Retention removes the working records and leaves the governed ones alone.
The run is bounded on purpose. Each class is deleted in one statement of at most Maximum rows per class rows, so one run cannot hold a long delete open across a maintenance window.
When it runs
Only when you run it, or when a batch job you created runs it. Earmark creates no batch job for it, and no setup check or tile tells you it is missing.
To run it now:
- Open Earmark > Periodic tasks > Earmark retention cleanup.
- Leave Maximum rows per class at 10000 and Purgeable class blank, unless you are working off a backlog (see Settings).
- Click OK.
To schedule it:
- Open the same dialog and go to the Run in the background tab.
- Switch Batch processing on, then set a Recurrence.
- Click OK.
A batch job runs in the company where you create it, and the timeline, the accrual event queue and the price proposal sessions are kept per company. Schedule the job in each company that uses Earmark. The execution exceptions workbench is different: it is shared by every company, so a run in any company also deletes the other companies' closed exceptions (see Effects on the rest of Earmark).
How often. The product prescribes no recurrence. The trade-off is the bound: each run deletes at most Maximum rows per class rows from each class, and whatever it leaves waits for the next run. A daily run keeps each delete small and is the easiest to reason about. If you run it less often, make sure the rows that become eligible between two runs fit inside the bound, or raise the bound; otherwise a backlog builds. Prefer a quiet time, such as overnight, because each class is deleted in one statement.
Settings
| Setting | Where | Default | Effect |
|---|---|---|---|
| Maximum rows per class | The run's dialog | 10000 | The largest number of rows the run deletes from any one class. It applies per class, so a run over all four classes can delete up to four times this number. Zero or a negative number is refused; there is no unlimited setting. Raise it to work off a backlog; lower it if the run competes with other overnight work. |
| Purgeable class | The run's dialog | Blank | Blank runs all four classes, which is what a scheduled run should do. To run one class alone, enter the table that holds it: MGCEarmarkEventLog (timeline), MGCEarmarkExecutionException (execution exceptions), MGCEarmarkAccrualEvent (accrual events) or MGCEarmarkPriceProposal (price proposal sessions). Any other name is refused. |
| Timeline retention (days) | Earmark > Setup > Earmark parameters, Retention tab | 365 | Timeline rows older than this are deleted. |
| Execution exception retention (days) | Same tab | 90 | Execution exceptions that are Resolved or Dismissed and older than this are deleted. |
| Accrual event retention (days) | Same tab | 90 | Accrual events that are Posted or Superseded and older than this are deleted. |
| Proposal session retention (days) | Same tab | 30 | Price proposal sessions older than this are deleted. |
Zero switches a class off. A day count of zero (or less) means that class is not purged at all: the run says "Retention for %1 is disabled because the day-count parameter %2 is not configured or is not greater than zero. Nothing was purged for this class." and moves on. To keep a class forever, set its day count to 0.
The day counts are read from the company the run is in, at the moment it runs. More about the Retention tab: Set company defaults and posting behavior and the configuration reference.
What it does
-
Checks the dialog. A bound of zero or less, or a Purgeable class that is not one of the four, is refused before anything is deleted.
-
Takes the four classes in turn (or the one you named): timeline and execution exceptions first, then accrual events and price proposal sessions.
-
For each class, reads its day count from Earmark parameters. If the day count is zero or less, it reports the class as disabled and skips it.
-
Works out the cutoff: the current date and time minus the day count.
-
Finds the eligible rows in the order they were written (lowest record ID first), up to Maximum rows per class:
Class Eligible when Never deleted Timeline The event's date and time is before the cutoff Execution exceptions Created before the cutoff, and Resolved or Dismissed Open and Retrying rows, at any age Accrual events Created before the cutoff, and Posted or Superseded Queued and Processing events, at any age Price proposal sessions Created before the cutoff -
Deletes those rows in one statement and reports "Earmark retention purged %1 row(s) from %2, older than %3 day(s)."
-
When every class is done, reports "Earmark retention cleanup finished. %1 record(s) were deleted in total; the line above shows the count for each class."
What is never purged. Only the four classes above are registered for retention, and the run cannot reach anything else. Parameters, deal groups, deals, targeting and posting rows, amendments, reason applicability, the posting profile, accrual instances, accrual transactions, journal registers, deal balances, control verdicts, dimension rules, reconciliation runs, price build-ups and their components, inbound pricing policies, claims and claim lines, settlement preferences, claim journal references, statement runs, migration batches and tie-outs, and configuration snapshots are all kept for good.
Before it can run
- Access. The menu item needs the Run Earmark retention cleanup privilege, in the Maintain Earmark configuration duty, which ships on the Accounting manager and System administrator roles (security reference).
- Day counts. Each class you want purged needs a day count above zero on the Retention tab. They ship set (365, 90, 90 and 30), so a new company is ready as installed.
- No module needs to be on. The menu item is available while every Earmark module is off, so you can clean up a company that has stopped using Earmark.
- A batch group, if you schedule it, as for any batch job.
What goes in and what comes out
| In | Out |
|---|---|
| The four tables, in the company the run is in (and the shared execution exceptions table) | Fewer rows in those tables |
| The four day counts on Earmark parameters | One information line per class, and a total line, in the infolog or the batch job's log |
| Maximum rows per class and Purgeable class from the dialog | Nothing else: no timeline row (a log does not log its own tidying), no workbench row, no business event |
Watching it
- The batch job. Open System administration > Inquiries > Batch jobs, find the job, and check its status,
next run time and history. The task's class is
MGCEarmarkRetentionCleanupController. The job's log holds the per-class lines, including any class that was disabled or failed. - The counts. The per-class line tells you how far behind you are: a class that reports exactly Maximum rows per class rows probably has more waiting, which the next run takes.
- No tile and no setup check. Nothing in Earmark lights up when the cleanup is not scheduled or has stopped. Check the batch job.
When it fails
| What you see | What it is | What to do |
|---|---|---|
| "The maximum rows per class must be greater than zero. ..." | A refusal at the dialog. Nothing ran. | Enter a bound above zero. |
| "%1 is not a registered Earmark purgeable class, so there is nothing for a run restricted to it to do. ..." | A refusal at the dialog. Nothing ran. | Leave Purgeable class blank, or enter one of the four table names. |
| "Retention for %1 is disabled because the day-count parameter %2 is not configured or is not greater than zero. ..." | Not a failure: that class is switched off. | Set a day count above zero if you want it purged. |
| "The retention purge for %1 did not complete and nothing was purged for this class. The remaining classes in this run are unaffected. The failure was: %2" | A failure in one class. The other classes still run. | Read the failure text. Fix the cause, then run that class alone with Purgeable class. |
A failed class is reported only in the infolog or the batch job's log. Unlike most Earmark failures, it does not create a row on the execution exceptions workbench, so the batch job's log is the only place to find it.
A re-run is always safe. Each run works out the eligible rows afresh, so a row already deleted is simply not found again, and a row left behind by the bound or by a failure is picked up by the next run. Nothing is skipped for good. The batch framework may also retry the task after an interruption, which is safe for the same reason. A deleted row cannot be brought back, so set the day counts before the first run.
Effects on the rest of Earmark
- Timeline. Rows older than Timeline retention (days) disappear from Earmark > Inquiries and reports > Earmark timeline and from the Earmark timeline FactBox on deals and claims, so an old deal can show fewer entries than it had acts. If your auditors need the timeline for longer than a year, raise the day count before the first run.
- Execution exceptions are shared by every company. The workbench is one table for the whole installation, so a run in any company deletes closed exceptions from every company, using the running company's Execution exception retention (days). If companies set different values, the shortest one that runs wins. Set the same value in every company. Open and Retrying rows are never deleted, so no outstanding failure is lost.
- Accrual events. Only Posted and Superseded events are deleted. The run never deletes an event the accrual event processor still has to work, so the two can run at the same time. The Accrual event queue page shows fewer completed rows afterwards.
- Price proposal sessions are working records of a price build. Deleting them does not change a built price.
- Locks. Each class's delete is one statement of at most Maximum rows per class rows. A large bound makes a longer statement on a busy table, which is why a quiet time suits the run best. New rows written during the run are not affected: the run deletes only rows it found before the cutoff.
Related
- Administrator: I want to schedule the other Earmark batch jobs
- Administrator: I want to check that the Earmark batch jobs are running
- Administrator: I want to review and retry execution exceptions
- Installation guide, section 7, Batch jobs to schedule
- Configuration reference
- Forms guide: Earmark parameters · Earmark execution exceptions · Earmark timeline
- Other operations pages: Accrual event processing · Background steps and retry