- 
                Notifications
    
You must be signed in to change notification settings  - Fork 207
 
          Link claimed_executions to processes via process_name
          #601
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            rosa
  wants to merge
  11
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
claimed-executions-by-process-name
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    
              
                    rosa
  
              
              commented
              
                  
                    Jul 21, 2025 
                  
              
              
            
            
| unless connection.column_exists?(:solid_queue_claimed_executions, :process_name) | ||
| add_column :solid_queue_claimed_executions, :process_name, :string | ||
| add_index :solid_queue_claimed_executions, :process_name | ||
| end | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This migration is idempotent because it is already included in the setup schema, for people who are installing Solid Queue for the first time. If there's a new update in the future with a new migration, people should be able to run all of them without any issues.
b18e146    to
    a06ef6b      
    Compare
  
    And include it in the host application's deprecators.
It's been a long time already since version 1.0 went out.
To be used as `bin/rails solid_queue:update` to copy new migrations. The new migration links claimed executions to processes with `process_name`, and replaces the unique index on processes on `supervisor_id, name` with just `name`, as we'll want the name to uniquely identify a process because we'll rely on that to release claimed executions, independently from the supervisor. Even though it was really unlikely to have a collision on name because these are set randomly with `SecureRandom.hex(10)`, in this way we guarantee it. fix
People installing Solid Queue for the first time will get the final schema. Migrations are idempotent so they can later update and run migrations without any problems.
We can only use this if new migrations have been run. If not, we just emit a deprecation warning and continue as before.
In the deprecation warning and upgrade instructions.
a06ef6b    to
    4e3ee40      
    Compare
  
    
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
That is, instead of linking them via the standard
process_id(claimed_execution.process_idandprocess.id).The reason for this change is that we're exploring the use of Solid Queue in a multi-tenanted setup, where we'll have an individual database per tenant, but a shared supervisor, dispatcher, scheduler, and workers for multiple tenants. We'll keep a supervisor-local database separated from the tenanted DBs, with just the
solid_queue_processestable. The supervisor will control the processes stored in that table in that local DB, whereas each tenant will use its own database with the remaining tables, which will contain the jobs and the job metadata.The consequence of this is that we can no longer rely on finding a process's in-flight jobs via its
id, because theidcan be (and most likely will be) duplicated across supervisors' local databases. The name, however, is randomly generated viaSecureRandom.hex(10), which, with a very high likelihood, guarantees unique names across supervisors' local DBs. In this way, if a process is killed, leaving in-flight jobs (claimed executions) behind, and we fail over a different supervisor with a different local DB, that supervisor will be able to know which claimed executions are orphaned.This requires a new migration, which is added here, but it's not enforced. The code still works without running the new migration, it just emits a deprecation warning like this:
This also includes a new
solid_queue:updatecommand to facilitate installing this migration and future migrations.cc @flavorjones