Embedding error with 3.6.0 beta 2

Hmm, haven’t seen this error recently.

However I have noticed one big change after updating recently, every night between 12:30am and 2:30am I will see a series of errors related to AI which are overloading the API rate limits.

I did not see these issues looking back through the logs to before the upgrade. Does discourse refresh the summaries or do other “refresh” work on every post on every night? We have a small forum with at most a few new posts a day. I don’t see any reason for Gemini rate limits to be exceeded every night at the same time unless it’s redoing everything for all historical posts.

Message

DiscourseAi::Completions::Endpoints::Gemini: status: 429 - body: {
  "error": {
    "code": 429,
    "message": "You exceeded your current quota, please check your plan and billing details. For more information on this error, head to: https://ai.google.dev/gemini-api/docs/rate-limits. To monitor your current usage, head to: https://ai.dev/usage?tab=rate-limit.\n* Quota exceeded for metric: generativelanguage.googleapis.com/generate_content_free_tier_requests, limit: 250\nPlease retry in 59.208757909s.",
    "status": "RESOURCE_EXHAUSTED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.QuotaFailure",
        "violations": [
          {
            "quotaMetric": "generativelanguage.googleapis.com/generate_content_free_tier_requests",
            "quotaId": "GenerateRequestsPerDayPerProjectPerModel-FreeTier",
            "quotaDimensions": {
              "location": "global",
              "model": "gemini-2.5-flash"
            },
            "quotaValue": "250"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.Help",
        "links": [
          {
            "description": "Learn more about Gemini API quotas",
            "url": "https://ai.google.dev/gemini-api/docs/rate-limits"
          }
        ]
      },
      {
        "@type": "type.googleapis.com/google.rpc.RetryInfo",
        "retryDelay": "59s"
      }
    ]
  }
}


Backtrace

activesupport-8.0.3/lib/active_support/broadcast_logger.rb:218:in `block in dispatch'
activesupport-8.0.3/lib/active_support/broadcast_logger.rb:217:in `map'
activesupport-8.0.3/lib/active_support/broadcast_logger.rb:217:in `dispatch'
activesupport-8.0.3/lib/active_support/broadcast_logger.rb:129:in `error'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:188:in `block (2 levels) in perform_completion!'
net-http-0.6.0/lib/net/http.rb:2433:in `block in transport_request'
net-http-0.6.0/lib/net/http/response.rb:320:in `reading_body'
net-http-0.6.0/lib/net/http.rb:2430:in `transport_request'
net-http-0.6.0/lib/net/http.rb:2384:in `request'
rack-mini-profiler-4.0.1/lib/patches/net_patches.rb:19:in `block in request_with_mini_profiler'
rack-mini-profiler-4.0.1/lib/mini_profiler/profiling_methods.rb:51:in `step'
rack-mini-profiler-4.0.1/lib/patches/net_patches.rb:18:in `request_with_mini_profiler'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:186:in `block in perform_completion!'
net-http-0.6.0/lib/net/http.rb:1632:in `start'
net-http-0.6.0/lib/net/http.rb:1070:in `start'
/var/www/discourse/plugins/discourse-ai/lib/completions/endpoints/base.rb:139:in `perform_completion!'
/var/www/discourse/plugins/discourse-ai/lib/completions/llm.rb:447:in `generate'
/var/www/discourse/plugins/discourse-ai/lib/configuration/llm_validator.rb:36:in `run_test'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:26:in `block (2 levels) in llm_errors'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:32:in `try_validate'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:26:in `block in llm_errors'
activerecord-8.0.3/lib/active_record/relation/batches.rb:88:in `each'
activerecord-8.0.3/lib/active_record/relation/batches.rb:88:in `block in find_each'
activerecord-8.0.3/lib/active_record/relation/batches.rb:172:in `block in find_in_batches'
activerecord-8.0.3/lib/active_record/relation/batches.rb:461:in `block in batch_on_unloaded_relation'
<internal:kernel>:187:in `loop'
activerecord-8.0.3/lib/active_record/relation/batches.rb:434:in `batch_on_unloaded_relation'
activerecord-8.0.3/lib/active_record/relation/batches.rb:289:in `in_batches'
activerecord-8.0.3/lib/active_record/relation/batches.rb:171:in `find_in_batches'
activerecord-8.0.3/lib/active_record/relation/batches.rb:87:in `find_each'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:24:in `each'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:24:in `filter_map'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:24:in `llm_errors'
/var/www/discourse/plugins/discourse-ai/app/services/problem_check/ai_llm_status.rb:13:in `call'
/var/www/discourse/app/models/problem_check.rb:169:in `run'
/var/www/discourse/app/models/problem_check.rb:155:in `run'
/var/www/discourse/app/jobs/regular/run_problem_check.rb:18:in `execute'
/var/www/discourse/app/jobs/base.rb:318:in `block (2 levels) in perform'
rails_multisite-7.0.0/lib/rails_multisite/connection_management/null_instance.rb:49:in `with_connection'
rails_multisite-7.0.0/lib/rails_multisite/connection_management.rb:17:in `with_connection'
/var/www/discourse/app/jobs/base.rb:305:in `block in perform'
/var/www/discourse/app/jobs/base.rb:301:in `each'
/var/www/discourse/app/jobs/base.rb:301:in `perform'
sidekiq-7.3.9/lib/sidekiq/processor.rb:220:in `execute_job'
sidekiq-7.3.9/lib/sidekiq/processor.rb:185:in `block (4 levels) in process'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:180:in `traverse'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
/var/www/discourse/lib/sidekiq/discourse_event.rb:6:in `call'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
/var/www/discourse/lib/sidekiq/pausable.rb:131:in `call'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
sidekiq-7.3.9/lib/sidekiq/job/interrupt_handler.rb:9:in `call'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:183:in `block in traverse'
sidekiq-7.3.9/lib/sidekiq/metrics/tracking.rb:26:in `track'
sidekiq-7.3.9/lib/sidekiq/metrics/tracking.rb:134:in `call'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:182:in `traverse'
sidekiq-7.3.9/lib/sidekiq/middleware/chain.rb:173:in `invoke'
sidekiq-7.3.9/lib/sidekiq/processor.rb:184:in `block (3 levels) in process'
sidekiq-7.3.9/lib/sidekiq/processor.rb:145:in `block (6 levels) in dispatch'
sidekiq-7.3.9/lib/sidekiq/job_retry.rb:118:in `local'
sidekiq-7.3.9/lib/sidekiq/processor.rb:144:in `block (5 levels) in dispatch'
sidekiq-7.3.9/lib/sidekiq/config.rb:39:in `block in <class:Config>'
sidekiq-7.3.9/lib/sidekiq/processor.rb:139:in `block (4 levels) in dispatch'
sidekiq-7.3.9/lib/sidekiq/processor.rb:281:in `stats'
sidekiq-7.3.9/lib/sidekiq/processor.rb:134:in `block (3 levels) in dispatch'
sidekiq-7.3.9/lib/sidekiq/job_logger.rb:15:in `call'
sidekiq-7.3.9/lib/sidekiq/processor.rb:133:in `block (2 levels) in dispatch'
sidekiq-7.3.9/lib/sidekiq/job_retry.rb:85:in `global'
sidekiq-7.3.9/lib/sidekiq/processor.rb:132:in `block in dispatch'
sidekiq-7.3.9/lib/sidekiq/job_logger.rb:40:in `prepare'
sidekiq-7.3.9/lib/sidekiq/processor.rb:131:in `dispatch'
sidekiq-7.3.9/lib/sidekiq/processor.rb:183:in `block (2 levels) in process'
sidekiq-7.3.9/lib/sidekiq/processor.rb:182:in `handle_interrupt'
sidekiq-7.3.9/lib/sidekiq/processor.rb:182:in `block in process'
sidekiq-7.3.9/lib/sidekiq/processor.rb:181:in `handle_interrupt'
sidekiq-7.3.9/lib/sidekiq/processor.rb:181:in `process'
sidekiq-7.3.9/lib/sidekiq/processor.rb:86:in `process_one'
sidekiq-7.3.9/lib/sidekiq/processor.rb:76:in `run'
sidekiq-7.3.9/lib/sidekiq/component.rb:10:in `watchdog'
sidekiq-7.3.9/lib/sidekiq/component.rb:19:in `block in safe_thread'