@@ -173,11 +173,10 @@ development:
173
173
NOTE: The key ` queue` from the database configuration needs to match the key
174
174
used in the configuration for `config.solid_queue.connects_to`.
175
175
176
- You can run the migrations for the `queue` database to ensure all the tables in
177
- queue database are created :
176
+ You can then run `db:prepare` to ensure the `queue` database in `development` has all the required tables :
178
177
179
178
` ` ` bash
180
- $ bin/rails db:migrate:queue
179
+ $ bin/rails db:prepare
181
180
` ` `
182
181
183
182
TIP : You can find the default generated schema for the `queue` database in
@@ -219,6 +218,13 @@ production:
219
218
migrations_paths: db/queue_migrate
220
219
` ` `
221
220
221
+ Make sure you run `db:prepare` so your database is ready to use :
222
+
223
+ ` ` ` bash
224
+ $ bin/rails db:prepare
225
+ ` ` `
226
+
227
+
222
228
# ## Configuration
223
229
224
230
The configuration options for Solid Queue are defined in `config/queue.yml`.
@@ -301,9 +307,11 @@ its own or at the end of a queue name to match all queues with the same prefix.
301
307
You can't specify queue names such as `*_some_queue`.
302
308
303
309
WARNING : Using wildcard queue names (e.g., `queues: active_storage*`) can slow
304
- down polling performance due to the need for a `DISTINCT` query to identify all
305
- matching queues, which can be slow on large tables. For better performance, it’s
306
- best to specify exact queue names instead of using wildcards.
310
+ down polling performance in SQLite and PostgreSQL due to the need for a `DISTINCT`
311
+ query to identify all matching queues, which can be slow on large tables in these RDBMS.
312
+ For better performance, it’s best to specify exact queue names instead of using
313
+ wildcards. Read more about this in [Queues specification and performance in the
314
+ Solid Queue documentation](https://github.com/rails/solid_queue?tab=readme-ov-file#queues-specification-and-performance)
307
315
308
316
Active Job supports positive integer priorities when enqueuing jobs (see
309
317
[Priority section](#priority)). Within a single queue, jobs are picked based on
@@ -414,14 +422,22 @@ end
414
422
415
423
# ## Transactional Integrity on Jobs
416
424
417
- By default, Solid Queue uses a separate database from your main application.
418
- This avoids issues with transactional integrity, which ensures that jobs are
419
- only enqueued if the transaction commits.
425
+ ⚠️ Having your jobs in the same ACID-compliant database as your application data
426
+ enables a powerful yet sharp tool : taking advantage of transactional integrity
427
+ to ensure some action in your app is not committed unless your job is also committed
428
+ and vice versa, and ensuring that your job won't be enqueued until the transaction
429
+ within which you're enqueuing it is committed. This can be very powerful and useful,
430
+ but it can also backfire if you base some of your logic on this behaviour,
431
+ and in the future, you move to another active job backend, or if you simply move
432
+ Solid Queue to its own database, and suddenly the behaviour changes under you.
433
+
434
+ Because this can be quite tricky and many people shouldn't need to worry about it,
435
+ by default Solid Queue is configured in a different database as the main app.
420
436
421
- However, if you use Solid Queue in the same database as your app, you can enable
422
- transactional integrity with Active Job’s `enqueue_after_transaction_commit`
423
- option which can be enabled for individual jobs or all jobs through
424
- `ApplicationJob` :
437
+ However, if you use Solid Queue in the same database as your app, you can make sure you
438
+ don't rely accidentallly on transactional integrity with Active Job’s
439
+ ` enqueue_after_transaction_commit ` option which can be enabled for individual jobs or
440
+ all jobs through `ApplicationJob` :
425
441
426
442
` ` ` ruby
427
443
class ApplicationJob < ActiveJob::Base
430
446
` ` `
431
447
432
448
You can also configure Solid Queue to use the same database as your app while
433
- avoiding transactional integrity issues by setting up a separate database
449
+ avoiding relying on transactional integrity by setting up a separate database
434
450
connection for Solid Queue jobs. Read more about [Transactional Integrity in the
435
451
Solid Queue
436
452
documentation](https://github.com/rails/solid_queue?tab=readme-ov-file#jobs-and-transactional-integrity)
@@ -457,7 +473,7 @@ Each task specifies a `class` or `command` and a `schedule` (parsed using
457
473
jobs, such as in the example for `MyJob` where `args` are passed. This can be
458
474
passed as a single argument, a hash, or an array of arguments that can also
459
475
include kwargs as the last element in the array. This allows jobs to run
460
- periodically or at specified times.
476
+ periodically at specified times.
461
477
462
478
Read more about [Recurring Tasks in the Solid Queue
463
479
documentation](https://github.com/rails/solid_queue?tab=readme-ov-file#recurring-tasks).
0 commit comments