Skip to content

Octopus doesn't work with Rails' schema cache #562

Description

@nebel95

I am using Rails 5 + Unicorn + Octopus with 3 Postresql database shards (all of them share the same schema). Everything seems to work well but I cannot seem to get schema cache to work, my database shards are always hit by queries like below when a web worker is started (I think the correct behavior should be no query at all):

SELECT a.attname
FROM
  (SELECT indrelid,
          indkey,
          generate_subscripts(indkey, $1) idx
   FROM pg_index
   WHERE indrelid = $2::regclass
     AND indisprimary ) i
JOIN pg_attribute a ON a.attrelid = i.indrelid
AND a.attnum = i.indkey[i.idx]
ORDER BY i.idx;

Is this a bug with octopus or am I doing something wrong here? I have schema cache enabled with config.active_record.use_schema_cache_dump = true in my Rails config file. Below is my Unicorn config:

preload_app true

after_fork do |server, worker|
  # START OF OCTOPUS SPECIFIC CONFIG
  ActiveRecord::Base.connection_proxy.initialize_shards(Octopus.config)
  # END OF OCTOPUS SPECIFIC CONFIG
end

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions