-
Notifications
You must be signed in to change notification settings - Fork 0
Comparing changes
Open a pull request
base repository: AppsDevTeam/background-queue
base: processWaitingJobs
head repository: AppsDevTeam/background-queue
compare: master
- 18 commits
- 16 files changed
- 4 contributors
Commits on Mar 25, 2026
-
Merge pull request #59 from AppsDevTeam/processWaitingJobs
Process waiting jobs
Configuration menu - View commit details
-
Copy full SHA for 2c876d1 - Browse repository at this point
Copy the full SHA 2c876d1View commit details
Commits on Jun 14, 2026
-
Configuration menu - View commit details
-
Copy full SHA for 900faca - Browse repository at this point
Copy the full SHA 900facaView commit details
Commits on Jun 16, 2026
-
Configuration menu - View commit details
-
Copy full SHA for d7940d3 - Browse repository at this point
Copy the full SHA d7940d3View commit details
Commits on Jun 18, 2026
-
Add CLAUDE.md with guidance for Claude Code
Documents the architecture of this background-queue library: - Dev commands (docker-up, init, test) - Core class and entry points (BackgroundQueue, processJob) - Two operating modes (cron vs broker) - Job state machine with exception-to-state mapping - serialGroup and WAITING mechanism - Implementation details (dual connection, middleware, broker abstraction) - Console commands and bulk insert Helps future Claude Code sessions get productive in the project faster.
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for cbfd0ea - Browse repository at this point
Copy the full SHA cbfd0eaView commit details -
Fix makefile config target to use .env.example
The config target should copy from .env.example, not .env.local. This ensures the base configuration template is available and consistent.
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for b6c7cd9 - Browse repository at this point
Copy the full SHA b6c7cd9View commit details -
Stop tracking generated Codeception test file
tests/Support/_generated/IntegrationTesterActions.php je automaticky generovaný soubor vytvářený Codeception při spuštění testů. Přidáno do .gitignore, odebrán z trackingu.
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for d5d32fd - Browse repository at this point
Copy the full SHA d5d32fdView commit details -
Fix integration tests compatibility with BackgroundQueue API changes
- Producer helper: update publish() signature (string $id, int $priority), add publishDie() - Logger: add void return types to all PSR-3 methods - BackgroundQueueTest: use Connection objects instead of DSN strings, fix publish() calls (ModeEnum::NORMAL, milliseconds instead of DateTimeImmutable), use reflection for private fetchAll/createQueryBuilder, update test expectations for delayed jobs, fix WaitingException test state to FINISHED, refetch entity after processJob(), fix JobNotFoundException assertions - ConsumeCommandTest: use Connection objects, update error message expectation - .gitignore: add tests/Support/_generated (auto-generated Codeception file)
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for 693c175 - Browse repository at this point
Copy the full SHA 693c175View commit details -
Add detailed test plan for priority + serialGroup, including a full b…
…roker-mode test Expands the "Návrh testů" section in docs/priority-serialgroup.md from a single reproduction test into a detailed set of six tests covering every aspect of the proposed solution: - Test 1: Jobs without serialGroup (regression - nothing should change) - Test 2a/2b: Ordering by (priority, ID) - unit + end-to-end cron mode - Test 3: PROCESSING clause (mutual exclusion) - serialization regression - Test 4: Group lock - acquire/release primitive with two connections - Test 5: Conditional claim in save() - RabbitMQ redelivery race - Test 6: Full broker-mode end-to-end - whole loop process → publish → consume → waiting Also documents the prerequisites: extending getBackgroundQueue() (priorities), extending the Mailer helper (processRecording + static $processOrder), direct raw DB connection access to simulate states, and extending the Producer helper (priority queues for Test 6). Coverage includes the interaction with _processWaitingJobs() and findOldestUnfinishedJobIdsByGroup() that the other tests do not exercise on their own.
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for 2e6fac1 - Browse repository at this point
Copy the full SHA 2e6fac1View commit details -
Implement integration tests for priority and serialGroup handling
Add comprehensive test suite covering priority ordering and serial group semantics: - Test 1: Verify jobs without serialGroup are unaffected by priority changes - Test 2a/2b: Validate predecessor selection by (priority, ID) and order in cron mode - Test 3: Ensure PROCESSING clause blocks higher-priority jobs (mutual exclusion) - Test 4: Guard for acquireGroupLock/releaseGroupLock implementation - Test 5: Guard for conditional claim in save() to prevent double-processing on redelivery - Test 6: Full broker-mode end-to-end test through priority queues and WAITING mechanism Extend test helpers: - Mailer: Add processRecording() callback with $processOrder tracking and serial group violation detection - Producer: Implement priority queue routing (general_<priority>), consume in priority order - BackgroundQueueTest: Add priorities parameter, rawConnection() helper, purge priority sub-queues All tests currently demonstrate expected behavior: 4 red (reproduce missing fixes), 3 green (guards).
Viktor Mašíček committedJun 18, 2026 Configuration menu - View commit details
-
Copy full SHA for 8ff1063 - Browse repository at this point
Copy the full SHA 8ff1063View commit details
Commits on Jun 19, 2026
-
Optimize findOldestUnfinishedJobIdsByGroup + harden serialGroup advis…
…ory lock Priority-aware head selection uses a JOIN with a derived table instead of a DEPENDENT SUBQUERY, eliminating O(W²) complexity and removing the need for a composite index. On top of that, the serialGroup advisory lock is hardened so it works correctly on both MySQL and PostgreSQL and never aborts a whole process() run / consumer on lock contention. Head selection / query changes: - findOldestUnfinishedJobIdsByGroup: rewrite to JOIN-based approach (O(W) linear, MySQL+PostgreSQL compatible) - Test 7: add deterministic regression test for head-selection logic with a priority-gap scenario - docs/priority-serialgroup.md: add performance analysis with benchmark table (1k-20k rows: ~160x-1100x speedup), compare variants (correlated subquery vs. derived table JOIN vs. composite index), explain why variant B was chosen (zero write-amplification, no index needed) - Test 2b: add sleep between process() calls to respect WAITING job postponement - Producer helper: implement delayed-message recirculation model (in-memory TTL buffer) to match real Producer behavior and prevent livelock on the highest-priority _processWaitingJobs Advisory lock hardening: - PostgreSQL: use single-arg pg_advisory_lock(bigint) with a composed 64-bit key ((namespace << 32) | crc32). The two-arg int4 variant would overflow on crc32 values > 2^31 ("integer out of range") - MySQL: hash serial_group via crc32 into the lock name. GET_LOCK names are capped at 64 chars and serial_group is VARCHAR(255), so a long group name would make GET_LOCK return NULL and silently fail - acquireGroupLock now returns bool instead of throwing. On failure processJob re-publishes the job to the broker and returns, so a single lock collision no longer aborts the whole process() run / consumer (the job is retried next time; in cron mode it is picked up by the next process() run) - Test 4: update to the new bool contract; docs updated incl. crc32 collision probability estimate (birthday problem over 2^32) All tests passing (26 tests, 71 assertions). No new indexes added - avoids write-amplification from frequent state changes. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>Configuration menu - View commit details
-
Copy full SHA for 7e353b3 - Browse repository at this point
Copy the full SHA 7e353b3View commit details
Commits on Jun 20, 2026
-
Merge pull request #61 from AppsDevTeam/priority-and-serialgroup
Priority and serialgroup
Configuration menu - View commit details
-
Copy full SHA for f21d046 - Browse repository at this point
Copy the full SHA f21d046View commit details
Commits on Jun 21, 2026
-
Improve memory handling for background queue processing
Addresses potential out-of-memory errors when processing a large number of background jobs. * Limits the number of background jobs fetched per iteration to 10,000. * Increases the PHP memory limit for the console `process` command to 1GB.
Configuration menu - View commit details
-
Copy full SHA for 34ec31a - Browse repository at this point
Copy the full SHA 34ec31aView commit details -
Implement job coalescing for background queue
Allows jobs to mark overlapping, unstarted jobs within the same serial group as REDUNDANT. This prevents redundant processing, for example, when a "recalculate from X" job covers the work of later "recalculate from Y (where Y >= X)" jobs.
Configuration menu - View commit details
-
Copy full SHA for 3142627 - Browse repository at this point
Copy the full SHA 3142627View commit details -
Lower background queue job fetch limit
Reduces the maximum number of background jobs fetched and processed per iteration from 10,000 to 1,000. While the previous increase to 10,000 aimed to reduce database round-trips, processing such a large batch concurrently could still lead to excessive memory consumption for specific job types, resulting in out-of-memory errors. This adjustment provides a better balance between database efficiency and peak memory usage during job execution.
Configuration menu - View commit details
-
Copy full SHA for c39ace4 - Browse repository at this point
Copy the full SHA c39ace4View commit details
Commits on Jun 22, 2026
-
Handle deadlocks in job coalescing
The `markCoalescedJobsRedundant` operation can encounter transient database deadlocks (1213) during concurrent writes. This could leave jobs stuck in a PROCESSING state. This change adds a retry mechanism with a back-off delay for the coalesce UPDATE to overcome these transient deadlocks. Additionally, a new index `(serial_group, coalesce_threshold)` is added to optimize the WHERE clause, reducing lock contention and preventing deadlocks by allowing targeted index scans.
Configuration menu - View commit details
-
Copy full SHA for 748a235 - Browse repository at this point
Copy the full SHA 748a235View commit details -
Mark jobs temporarily failed on persistent coalescing deadlocks
When the `markCoalescedJobsRedundant` operation fails due to a deadlock that persists even after internal retries, the job would otherwise remain stuck in a PROCESSING state. This ensures such jobs are transitioned to TEMPORARILY_FAILED, allowing them to be picked up for reprocessing in a subsequent run, preventing them from getting permanently stuck.
Configuration menu - View commit details
-
Copy full SHA for 1c78ab5 - Browse repository at this point
Copy the full SHA 1c78ab5View commit details
Commits on Jun 28, 2026
-
Allow dynamic AMQP arguments based on queue name
Introduces an optional `queueArguments` parameter to the `Manager` constructor. This enables applying specific AMQP arguments, such as `x-single-active-consumer`, to queues whose names contain a defined string. This provides more granular and flexible control over queue behavior without requiring separate queue parameter definitions for each unique configuration.
Configuration menu - View commit details
-
Copy full SHA for f4c3fe4 - Browse repository at this point
Copy the full SHA f4c3fe4View commit details -
Order background jobs by ID for consistent processing
Ensures jobs are processed in a predictable and consistent order, preventing potential starvation of older jobs.
Configuration menu - View commit details
-
Copy full SHA for fc912a3 - Browse repository at this point
Copy the full SHA fc912a3View commit details
This comparison is taking too long to generate.
Unfortunately it looks like we can’t render this comparison for you right now. It might be too big, or there might be something weird with your repository.
You can try running this command locally to see the comparison on your machine:
git diff processWaitingJobs...master