Skip to content

refactor(queue/mysql): clean up logging, metrics, errors, schema indexes, and write perf#128

Closed
behinddwalls wants to merge 1 commit into
preetam/queuefrom
preetam/queue-err
Closed

refactor(queue/mysql): clean up logging, metrics, errors, schema indexes, and write perf#128
behinddwalls wants to merge 1 commit into
preetam/queuefrom
preetam/queue-err

Conversation

@behinddwalls
Copy link
Copy Markdown
Collaborator

@behinddwalls behinddwalls commented Mar 8, 2026

Summary

  • Add queue_mysql_ prefix to all Named() and SubScope() calls for consistent log/metric scoping
  • Rename struct field metrics to scope, use bare metrics import for core/metrics
  • Remove redundant logs, elevate important ones (e.g. DLQ message-not-found to Warn)
  • Add domain sentinel errors: ErrPublisherClosed, ErrSubscriberClosed, ErrLeaseExpired, ErrAlreadyAcknowledged
  • Fix terse error messages to include topic/partition context throughout
  • Remove unused constants (tagErrorType, errorBeginTx, errorCommit)
  • Drop redundant indexes: idx_consumer_group (PK prefix covers it), idx_leased_by (no solo query)
  • Drop idx_topic_id by refactoring Delete/MoveToDLQ/SetVisibilityTimeout to accept partitionKey — all queries now use idx_topic_partition_id, reducing write amplification on the messages table (3 secondary indexes → 2)
  • Add inline index reasoning comments to all 4 schema files
  • Update README.md: fix timeouts, add fair share partitioning and error types sections
  • Update sql-queue-rfc.md: add heartbeat table, fair share, DLQ topic reuse, observability metrics

Test plan

  • make test — all 27 unit tests pass
  • make integration-test — verify with real MySQL

…xes, and write perf

- Add queue_mysql_ prefix to all Named() and SubScope() calls
- Rename struct field `metrics` to `scope`, use bare `metrics` import for core/metrics
- Remove redundant logs, elevate important ones (e.g. DLQ not-found to Warn)
- Add domain sentinel errors: ErrPublisherClosed, ErrSubscriberClosed, ErrLeaseExpired, ErrAlreadyAcknowledged
- Fix terse error messages to include topic/partition context
- Remove unused constants (tagErrorType, errorBeginTx, errorCommit)
- Drop redundant indexes: idx_consumer_group (PK prefix), idx_leased_by (no solo query)
- Drop idx_topic_id by refactoring Delete/MoveToDLQ/SetVisibilityTimeout to accept partitionKey,
  so all queries use idx_topic_partition_id — reduces write amplification on messages table
- Add inline index reasoning comments to all schema files
- Update README.md: fix timeouts, add fair share and error types sections
- Update sql-queue-rfc.md: add heartbeat table, fair share, DLQ reuse, observability
@behinddwalls behinddwalls changed the title refactor(queue/mysql): clean up logging, metrics, and error handling refactor(queue/mysql): clean up logging, metrics, errors, schema indexes, and write perf Mar 8, 2026
@behinddwalls
Copy link
Copy Markdown
Collaborator Author

Superseded — changes folded into stacked PRs from preetam/queue

@behinddwalls behinddwalls deleted the preetam/queue-err branch March 8, 2026 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant