-
Notifications
You must be signed in to change notification settings - Fork 0
MySQL timeout during batch analysis - sentiments module only #4
Description
Bug Description
The sentiments analyzer consistently fails with MySQL timeout errors during batch processing, while all other analyze modules (brand voice, content marketing audit, content security audit) work correctly.
Note: Not sure if related but I recently renamed this module: https://www.drupal.org/project/project_composer/issues/3539699
It was renamed from analyze_ai_sentiment to analyze_ai_sentiment (plural) to work around a drupal.org infrastructure problem. Not sure if related but it's something we can look into, search and replace can have some nasty side-effects.
Steps to reproduce
Video
Showing you video of both the steps working correctly on ai_analyze_security_audit module and breaking in ai_analyze_sentiments:
https://app.screencastify.com/watch/4aZ8UIEgeZz84TSdW8Ni
Steps
- Install and enable https://www.drupal.org/project/analyze_ai_sentiments
- Go to /admin/config/content/analyze-settings and enable Sentiments analyzer on some (node) type
- Go to /admin/config/analyze/sentiments/batch and run the batch feature on that node type (preferable with not too many nodes to save AI costs)
Expected result: Successfully analyzed n items
Bug behavior: An AJAX HTTP error occurred. HTTP Result Code: 500 Debugging information follows. Path: /batch?id=31&op=do_nojs&op=do StatusText: 500 Service unavailable (with message) ResponseText: The website encountered an unexpected error. Try again later.
Error Details
Error Message:
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away: SELECT 1 FROM information_schema.tables WHERE ("table_schema" = :db_condition_placeholder_8) AND ("table_name" = :db_condition_placeholder_9)
Error Location:
/web/core/lib/Drupal/Core/Config/DatabaseStorage.php:121- Occurs during batch processing operations
- Triggered by automated cron after batch operation timeout
Environment
- Working Modules: Brand Voice, Content Marketing Audit, Content Security Audit all process batches successfully
- Failing Module: Sentiments Analysis only
- Individual Analysis: Works perfectly when analyzing single entities through the UI
- Batch Analysis: Consistently times out and fails
Investigation Summary
What We've Confirmed:
- Plugin Manager Issue (Fixed): Initially used
DefaultPluginManagerinstead ofAnalyzePluginManager- this was corrected to match working modules - Batch Processing Logic: Confirmed identical to working modules (5 entities per chunk)
- Service Dependencies: All properly injected and configured
- Individual Analysis: Functions correctly, suggesting the analyzer plugin itself works
What We've Tried:
- ✅ Fixed plugin manager from
DefaultPluginManagertoAnalyzePluginManager - ❌ Reduced batch size from 5 to 1 entity per chunk - did not resolve timeout
- ✅ Compared batch service implementations - found to be identical to working modules
- ✅ Verified service configuration - matches other analyze modules
Code Comparison Results:
- Batch Forms: Identical structure across all modules
- Batch Services: Same processing logic and error handling
- Plugin Managers: Now correctly using
AnalyzePluginManager - Service Injection: Properly configured
Hypothesis
The sentiments analysis appears to be significantly more complex or slower than other analyze operations, causing individual entity analysis to exceed MySQL's connection timeout threshold during batch processing. This suggests the AI analysis requests themselves may be more intensive.
Current Status
- ✅ Brand Voice: Batch processing works
- ✅ Content Marketing Audit: Batch processing works
- ✅ Content Security Audit: Batch processing works
- ❌ Sentiments Analysis: Batch processing fails with MySQL timeouts
The issue appears to be specific to the computational complexity or duration of the sentiments analysis AI requests rather than the batch processing infrastructure itself.