Skip to content

fix: implement MySQL scheduler methods#7354

Open
kaiisfree wants to merge 2 commits intoagno-agi:mainfrom
kaiisfree:fix/mysql-scheduler-methods
Open

fix: implement MySQL scheduler methods#7354
kaiisfree wants to merge 2 commits intoagno-agi:mainfrom
kaiisfree:fix/mysql-scheduler-methods

Conversation

@kaiisfree
Copy link
Copy Markdown
Contributor

Summary

Changes

libs/agno/agno/db/mysql/schemas.py

  • Added SCHEDULE_TABLE_SCHEMA with MySQL-compatible types (JSON, VARCHAR with explicit lengths)
  • Added _get_schedule_runs_table_schema() with FK reference to schedules table
  • Updated get_table_schema_definition() to handle new table types

libs/agno/agno/db/mysql/mysql.py (sync)

  • Added schedules and schedule_runs to _get_table()
  • Implemented: get_schedule, get_schedule_by_name, get_schedules, create_schedule, update_schedule, delete_schedule, claim_due_schedule, release_schedule, create_schedule_run, update_schedule_run, get_schedule_run, get_schedule_runs

libs/agno/agno/db/mysql/async_mysql.py (async)

  • Same 12 methods as async variants

MySQL-specific adaptations

  • claim_due_schedule: Uses SELECT...FOR UPDATE SKIP LOCKED + UPDATE in a transaction (MySQL doesn't support UPDATE...RETURNING)
  • JSON type instead of JSONB
  • Explicit VARCHAR lengths for indexed string columns
  • FK handling adapted for MySQL schema patterns

Test plan

  • Verify scheduler CRUD operations work with MySQL 8.0+
  • Verify claim_due_schedule concurrent safety with SKIP LOCKED
  • Verify delete_schedule cascades to schedule_runs
  • Verify async variants match sync behavior

🤖 Generated with Claude Code

Add missing scheduler methods to MySQLDb and AsyncMySQLDb backends:
- get_schedule, get_schedule_by_name, get_schedules
- create_schedule, update_schedule, delete_schedule
- claim_due_schedule, release_schedule
- create_schedule_run, update_schedule_run, get_schedule_run, get_schedule_runs

Key MySQL-specific adaptations:
- claim_due_schedule uses SELECT...FOR UPDATE SKIP LOCKED + UPDATE
  (MySQL doesn't support UPDATE...RETURNING)
- JSON type instead of JSONB
- Explicit VARCHAR lengths for indexed columns

Also adds schedule and schedule_runs table schemas to MySQL schema definitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kaiisfree kaiisfree requested a review from a team as a code owner April 5, 2026 13:07
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 5, 2026

PR Triage

Missing tests: This PR modifies source code but does not include any test changes. Please add or update tests to cover your changes.

Cover schedule CRUD (get/create/update/delete), claim/release
atomicity with SELECT FOR UPDATE, schedule runs, pagination,
and schema definitions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kaiisfree
Copy link
Copy Markdown
Contributor Author

Tests were added in the second commit (test: add unit tests for MySQL scheduler methods). 43 unit tests covering all implemented scheduler methods — this comment was posted before the test commit was pushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] MySQLDb in Agno 2.5.10 does not implement Scheduler methods (claim_due_schedule, etc.)

1 participant