CodamAIDocs
Topicdone

Execution and limits

Where a render runs: the caller's thread and a bounded pool. Timeout, size limits for payload, attachments and output, a full queue, the template's sandbox and which resources are refused.

Variants
renderedqueue full → render-capacity-exhaustedtoo slow → render-timeoutcaller interrupted → render-interruptedoutput too large → render-output-too-largeresource refused → render-resource-refusederror in the template → template-render-failed

What this is about

Rendering costs computing time. So that many simultaneous requests do not bring an application to a halt, CRMS renders in a bounded pool: a fixed number of threads with a short queue in front. On top of that come limits for time and size, and a sandbox: a closed environment in which the template runs and from which it reaches nothing.

Where each step runs

sequenceDiagram
    participant C as Client
    participant A as CRMS (caller's thread)
    participant P as CRMS (render pool)
    participant DB as Database
    C->>A: render request
    A->>DB: read caller, template, revision
    A->>A: check format, mode, payload, attachments
    A->>P: job into the pool
    Note over P: run template, produce format, seal for FINAL
    P-->>A: bytes (or error, timeout)
    A->>DB: store for FINAL, in the caller's transaction
    A-->>C: document
  1. On the caller’s thread: who is asking, language, template and revision, all checks. CRMS reads the database here, in the context of the request.
  2. In the pool: run the template and produce the format, under the timeout and the output limit. For FINAL, the seal afterwards.
  3. Back on the caller’s thread: a final document is stored before the bytes go back.

The limits

LimitVariableDefaultWhat happens beyond it
render threadsCODAMAI_CRMS_RENDER_THREADSnumber of processors–
queueCODAMAI_CRMS_RENDER_QUEUE50 jobs503 render-capacity-exhausted, at once
timeoutCODAMAI_CRMS_RENDER_TIMEOUT30 sthe job is cancelled, 504 render-timeout
largest documentCODAMAI_CRMS_RENDER_MAX_OUTPUT50 MiB422 render-output-too-large
largest payloadCODAMAI_CRMS_PAYLOAD_MAX_BYTES5 MiB422 payload-rejected with payload-too-large
number of attachmentsCODAMAI_CRMS_ATTACHMENTS_MAX_COUNT200422 payload-rejected with attachments-too-many
size of all attachmentsCODAMAI_CRMS_ATTACHMENTS_MAX_BYTES50 MiB422 payload-rejected with attachments-too-large

Over REST, the whole body is also bounded before CRMS reads it: payload limit plus 64 KiB for the other fields plus the attachment limit in Base64 (four thirds) plus 512 bytes per allowed attachment. GET /crms/capabilities returns the current values under limits. How you set them is described in Environment variables.

The output limit applies twice: to the markup the template writes, and to the bytes the format produces. A loop that writes text endlessly therefore never fills the memory.

What can happen while running

Room in the pool?Done within the timeout?Output within the limit?Result
no––503 render-capacity-exhausted: try again later
yesno–504 render-timeout: the job is interrupted
yesyesno422 render-output-too-large
yesyesyesdocument

If the caller itself is interrupted, for example because its request was cancelled, CRMS cancels the job too: 503 render-interrupted. A render never keeps running for nobody. An unexpected error in the pool is 500 render-failed. The details are then only in the log.

The template’s sandbox

Tenants and users write templates too. That is why FreeMarker, the template language, runs restricted:

WhatHow it is in CRMS
?newcreates no class at all
?apiswitched off. The template only sees text, numbers, booleans, dates, lists and maps and never reaches a method
include, importfind nothing. A revision is exactly one source, without a file system
Escapingautomatic: XHTML for DOCUMENT, XML for TABLE and WORD
Markup from the payloadonly through crms.svg, see Pictures and SVG
Endless loopis interrupted at the timeout, because the sandbox checks for interruption inside loops

What else the template language can do is described in The template language. An error in the template comes back as a key with line and column: template-syntax-error|<line>|<column> when reading, template-render-failed|<line>|<column> when running, for example for a missing value.

Which resources a format loads

A format loads nothing from the network and nothing from the file system. It gets everything in memory.

FormatAllowedRefused
HTMLasset:<name> becomes a data: addressan asset the revision does not have: render-asset-unknown
PDFasset:<name>, attachment:<name>, embedded fonts from CRMSany other address, including http, https, file, jar, ftp, and unknown names: render-resource-refused
DOCXasset:<name> in <pkg:binaryData>, hyperlinksany other external relationship: render-resource-refused. An unknown asset: render-asset-unknown. A DTD: render-word-invalid
XLSX, CSV, ODSonly the table documenta DTD or an unknown element: render-table-invalid

Pitfalls

Next

Search