Data secretaries - panel and truncating archives
A data secretary is a background thread of the server that processes the data stored in buffer tables: the case index (changes of cases waiting to be written to the Lucene index), the data transmitted from BPM, the statistics, the migrations and the Excel reports. Mercury DB (HgDB) 3.0 lets a system administrator see the state of the secretaries and their buffers, wake them up, repair a stuck buffer and truncate the archives without access to the database: in a panel in the browser and through a REST service.
- The panel and the state service describe the node that answered, not the whole cluster. Choose the node on the page (the node bar), or use
?n=<node>with the load balancer. - The operations need the role
mrc-sysadmin: the panel after signing in with the form (single sign-on with the other applications), the REST service with an OAuth token that has the scopemrc-sysadminfor the path/rest/service/**(see Changing logging levels for the token request).
The panel

The page /mercury-ws-app/admin/secretaries (a box on the home page and the link in the bar of the administration pages) lists the secretaries of the node in a fixed order:
| Secretary | Buffers |
|---|---|
Case index (caseIndex) | current, bulk and archive |
BPM process instances (bpmBPDInstance) | buffer, archive |
BPM tasks (bpmTask) | buffer, narrative, archive, narrativeArchive |
Statistics (statsBuffer), case migrations (caseMigrator), report exports and imports (reportExport, reportImport), cache of case attribute definitions (caseAttributes) | state only |
For each secretary the panel shows whether it is working and the number of rows of each buffer (a count that fails is shown as "could not be counted"). The page can refresh itself at the chosen interval. Wake up wakes a secretary and starts it when it is not working; in a cluster the request is handled by the MASTER node.
Preview of a buffer and a stuck package
The link preview at a buffer shows its rows, oldest first (at most a fixed number): the id, the case, the operation, the source and the SCN. The SCN number is the number of the package that the secretary assigned the row to:
- a row without an SCN waits to be taken by the secretary; Wake up makes it work,
- a row with an SCN was assigned to a package that has not been finished (for example the node stopped in the middle of the work). Reset SCN (for one row, or for all the rows that have one) makes the secretary take the row again and wakes it up. The reset is refused while the secretary is working.
Truncating archives
The archive buffers (archive of the case index and of the BPM secretaries, narrativeArchive of tasks) only grow. The panel truncates them: the link truncate at an archive asks how many of the last days have to stay and deletes the older rows in the background.
- The age of a row: in the archive of the case index it is the time of archiving; in the BPM archives the business date of the row (instances:
create_datetime; tasks:sent_datetimeorrcvd_datetime; narratives: the age of the parent task). Rows without a date stay. - The lower limit. The number of days cannot be less than the parameter
mercury.archive.truncate.minKeepDaysofmercury.properties(10 by default; at most 36500 can be given). The reason: the archive of the case index is used to align the index after a backup is restored (Backup and restore of the Lucene index), so it has to cover the time since the last backup. - Irreversible. The panel asks for confirmation; deleted rows cannot be recovered.
- Progress. The operation is asynchronous. The buffer shows "archive truncation in progress: N of M rows deleted", and afterwards "last archive truncation: N rows deleted, finished ...", or the error.
One truncation at a time (lock per buffer)
The truncation concerns the database, so it covers the whole cluster, and a given archive buffer can be truncated by one node at a time. For the time of the work the node sets a lock in the table IGO_LUC_LOCK (one lock per buffer). The other nodes reject a new request for that buffer (the message names the node that truncates) and show the running truncation in the state of the buffer ("in progress on the node ..."). Truncating different buffers at the same time is allowed. A lock left by a node that was switched off or restarted is removed by the next request on its own.
REST service
The service SecretariesExtRest has the address /rest/service/SecretariesExtRest/{operation}. All operations use POST, accept a JSON request (the field context is optional, the server takes the user and the roles from the token) and return a JSON envelope with errorCode, errorMessage and the data in dto. The full description with the parameters is in Swagger UI (/mercury-ws-app/swagger-ui).
| Operation | What it does |
|---|---|
getSecretariesState | The state of the node: nodeName, timestamp, minKeepDays and the list secretaries (id, working, buffers: id, table, size, error and truncate) |
wakeUpCaseIndexSecretary, wakeUpBPDInstanceBufferSecretary, wakeUpTaskBufferSecretary, wakeUpCaseMigratorSecretary, wakeUpReportExportSecretary, wakeUpReportImportSecretary, wakeUpStatsBufferSecretary, wakeUpCaseAttributesSecretary | Wakes up the given secretary (starts it when it is not working) |
truncateArchiveBuffer | Starts truncating an archive: the parameter archive (the key bpmBPDInstance.archive, bpmTask.archive, bpmTask.narrativeArchive or caseIndex.archive, the table name or the entity name) and keepDays; returns the status at once (running, total, deleted, error, ownerNode, remote) |
Example (the token from POST /rest/token with the scope mrc-sysadmin):
curl -k -X POST -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' \
-d '{"archive":"caseIndex.archive","keepDays":30}' \
https://host:31443/mercury-ws-app/rest/service/SecretariesExtRest/truncateArchiveBuffer