Skip to content

Commit 91c950f

Browse files
authored
docs: improve queueName docs to avoid high cardinality (#558)
2 parents ae40946 + 0042f00 commit 91c950f

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/interfaces.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ export interface AddJobsJobSpec<
8484

8585
/**
8686
* The queue to run this task under (only specify if you want jobs in this
87-
* queue to run serially). (Default: null)
87+
* queue to run serially). Avoid using high cardinality values (e.g., random
88+
* strings, UUIDs, timestamps) as this degrades performance and requires
89+
* periodic database cleanup. (Default: null)
8890
*/
8991
queueName?: string;
9092

@@ -336,7 +338,9 @@ export interface CronItemOptions {
336338
/** Optionally override the default job max_attempts */
337339
maxAttempts?: number;
338340

339-
/** Optionally set the job queue_name to enforce that the jobs run serially */
341+
/** Optionally set the job queue_name to enforce that the jobs run serially.
342+
* Avoid using high cardinality values (e.g., random strings, UUIDs, timestamps)
343+
* as this degrades performance and requires periodic database cleanup. */
340344
queueName?: string;
341345

342346
/** Optionally set the job priority */
@@ -586,7 +590,9 @@ export interface Cron {
586590
export interface TaskSpec {
587591
/**
588592
* The queue to run this task under (only specify if you want jobs in this
589-
* queue to run serially). (Default: null)
593+
* queue to run serially). Avoid using high cardinality values (e.g., random
594+
* strings, UUIDs, timestamps) as this degrades performance and requires
595+
* periodic database cleanup. (Default: null)
590596
*/
591597
queueName?: string;
592598

website/docs/library/add-job.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ The `addJob` arguments are as follows:
4242
(see [Replacing and updating jobs](../job-key.md#replacingupdating-jobs) and
4343
[removing jobs](../job-key.md#removing-jobs))
4444

45+
:::warning Avoid high cardinality in queue names
46+
47+
Avoid using high cardinality values (e.g., random strings, UUIDs, timestamps)
48+
for queue names as this will create many dead queues that degrade performance
49+
and require [periodic database cleanup](../admin-functions.md#gc_job_queues). If
50+
you find yourself needing to run the `GC_JOB_QUEUES` cleanup task regularly,
51+
you're likely using queue names incorrectly.
52+
53+
:::
54+
4555
Example:
4656

4757
```js

website/docs/library/add-jobs.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export interface AddJobsJobSpec {
5858

5959
/**
6060
* The queue to run this task under (only specify if you want jobs in this
61-
* queue to run serially). (Default: null)
61+
* queue to run serially). Avoid using high cardinality values (e.g., random
62+
* strings, UUIDs, timestamps) as this degrades performance and requires
63+
* periodic database cleanup. (Default: null)
6264
*/
6365
queueName?: string;
6466

website/docs/sql-add-job.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ this underlying `add_job` SQL function.
2222
what to do, or an array of one or more of these objects for &ldquo;batch
2323
jobs&rdquo; (defaults to an empty object).
2424
- `queue_name` &mdash; if you want certain tasks to run one at a time, add them
25-
to the same named queue (defaults to `null`).
25+
to the same named queue. Avoid using high cardinality values (e.g., random
26+
strings, UUIDs, timestamps) as this degrades performance and requires periodic
27+
database cleanup (defaults to `null`).
2628
- `run_at` &mdash; a timestamp after which to run the job; defaults to now.
2729
- `max_attempts` &mdash; if this task fails, how many times should we retry it?
2830
(defaults to `25`. Must be castable to `smallint`).

0 commit comments

Comments
 (0)