Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ insert_res.job
insert_res.unique_skipped_as_duplicated
```

### Custom advisory lock prefix

Unique job insertion takes a Postgres advisory lock to make sure that its uniqueness check still works even if two conflicting insert operations are occurring in parallel. Postgres advisory locks share a global 64-bit namespace, which is a large enough space that it's unlikely for two advisory locks to ever conflict, but to _guarantee_ that River's advisory locks never interfere with an application's, River can be configured with a 32-bit advisory lock prefix which it will use for all its locks:

```ruby
client = River::Client.new(mock_driver)
```

Doing so has the downside of leaving only 32 bits for River's locks (64 bits total - 32-bit prefix), making them somewhat more likely to conflict with each other.

## Inserting jobs in bulk

Use `#insert_many` to bulk insert jobs as a single operation for improved efficiency:
Expand Down
6 changes: 0 additions & 6 deletions lib/insert_opts.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,6 @@ def initialize(
# given job kind, a single instance is allowed for each combination of args
# and queues. If either args or queue is changed on a new job, it's allowed to
# be inserted as a new job.
#
# Uniquenes is checked at insert time by taking a Postgres advisory lock,
# doing a look up for an equivalent row, and inserting only if none was found.
# There's no database-level mechanism that guarantees jobs stay unique, so if
# an equivalent row is inserted out of band (or batch inserted, where a unique
# check doesn't occur), it's conceivable that duplicates could coexist.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could've changed this to talk about unique_key, but the paragraph was essentially a block warning not to insert unique jobs out of band, so felt like it wasn't really needed anymore.

class UniqueOpts
# Indicates that uniqueness should be enforced for any specific instance of
# encoded args for a job.
Expand Down
Loading