2

Estoy creando un proyecto en rails 7.1.3, y nada más al configurar mi base de datos postgres en el archivo /config/database.yml y ejecutar rails server me da el siguiente error:

#<Thread:0x00005648c3de4e20@puma srv tp 002 /home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:113 sleep> terminated with exception (report_on_exception is true):
/home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.1.3/lib/active_record/migration.rb:641:in `synchronize': machine stack overflow in critical region (fatal)
#<Thread:0x00005648c3de5280@puma srv tp 001 /home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:113 sleep> terminated with exception (report_on_exception is true):
/home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/activerecord-7.1.3/lib/active_record/migration.rb:641:in `synchronize': machine stack overflow in critical region (fatal)

Este es mi archivo gemfile:

source "https://rubygems.org"

ruby "3.0.0"

# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.3"

# Use postgresql as the database for Active Record
gem "pg", "~> 1.1"

# Use the Puma web server [https://github.com/puma/puma]
gem "puma", ">= 5.0"

# Build JSON APIs with ease [https://github.com/rails/jbuilder]
# gem "jbuilder"

# Use Redis adapter to run Action Cable in production
# gem "redis", ">= 4.0.1"

# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
# gem "kredis"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mswin mswin64 mingw x64_mingw jruby ]

# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", require: false

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible
# gem "rack-cors"

group :development, :test do
  # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
  gem "debug", platforms: %i[ mri mswin mswin64 mingw x64_mingw ]
end

group :development do
  # Speed up commands on slow machines / big apps [https://github.com/rails/spring]
  # gem "spring"
end

Este es mi archive Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actioncable (7.1.3)
      actionpack (= 7.1.3)
      activesupport (= 7.1.3)
      nio4r (~> 2.0)
      websocket-driver (>= 0.6.1)
      zeitwerk (~> 2.6)
    actionmailbox (7.1.3)
      actionpack (= 7.1.3)
      activejob (= 7.1.3)
      activerecord (= 7.1.3)
      activestorage (= 7.1.3)
      activesupport (= 7.1.3)
      mail (>= 2.7.1)
      net-imap
      net-pop
      net-smtp
    actionmailer (7.1.3)
      actionpack (= 7.1.3)
      actionview (= 7.1.3)
      activejob (= 7.1.3)
      activesupport (= 7.1.3)
      mail (~> 2.5, >= 2.5.4)
      net-imap
      net-pop
      net-smtp
      rails-dom-testing (~> 2.2)
    actionpack (7.1.3)
      actionview (= 7.1.3)
      activesupport (= 7.1.3)
      nokogiri (>= 1.8.5)
      racc
      rack (>= 2.2.4)
      rack-session (>= 1.0.1)
      rack-test (>= 0.6.3)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
    actiontext (7.1.3)
      actionpack (= 7.1.3)
      activerecord (= 7.1.3)
      activestorage (= 7.1.3)
      activesupport (= 7.1.3)
      globalid (>= 0.6.0)
      nokogiri (>= 1.8.5)
    actionview (7.1.3)
      activesupport (= 7.1.3)
      builder (~> 3.1)
      erubi (~> 1.11)
      rails-dom-testing (~> 2.2)
      rails-html-sanitizer (~> 1.6)
    activejob (7.1.3)
      activesupport (= 7.1.3)
      globalid (>= 0.3.6)
    activemodel (7.1.3)
      activesupport (= 7.1.3)
    activerecord (7.1.3)
      activemodel (= 7.1.3)
      activesupport (= 7.1.3)
      timeout (>= 0.4.0)
    activestorage (7.1.3)
      actionpack (= 7.1.3)
      activejob (= 7.1.3)
      activerecord (= 7.1.3)
      activesupport (= 7.1.3)
      marcel (~> 1.0)
    activesupport (7.1.3)
      base64
      bigdecimal
      concurrent-ruby (~> 1.0, >= 1.0.2)
      connection_pool (>= 2.2.5)
      drb
      i18n (>= 1.6, < 2)
      minitest (>= 5.1)
      mutex_m
      tzinfo (~> 2.0)
    base64 (0.2.0)
    bigdecimal (3.1.6)
    bootsnap (1.18.3)
      msgpack (~> 1.2)
    builder (3.2.4)
    concurrent-ruby (1.2.3)
    connection_pool (2.4.1)
    crass (1.0.6)
    date (3.3.4)
    debug (1.9.1)
      irb (~> 1.10)
      reline (>= 0.3.8)
    drb (2.2.0)
      ruby2_keywords
    erubi (1.12.0)
    globalid (1.2.1)
      activesupport (>= 6.1)
    i18n (1.14.1)
      concurrent-ruby (~> 1.0)
    io-console (0.7.2)
    irb (1.11.2)
      rdoc
      reline (>= 0.4.2)
    loofah (2.22.0)
      crass (~> 1.0.2)
      nokogiri (>= 1.12.0)
    mail (2.8.1)
      mini_mime (>= 0.1.1)
      net-imap
      net-pop
      net-smtp
    marcel (1.0.2)
    mini_mime (1.1.5)
    minitest (5.22.2)
    msgpack (1.7.2)
    mutex_m (0.2.0)
    net-imap (0.4.10)
      date
      net-protocol
    net-pop (0.1.2)
      net-protocol
    net-protocol (0.2.2)
      timeout
    net-smtp (0.4.0.1)
      net-protocol
    nio4r (2.7.0)
    nokogiri (1.16.2-x86_64-linux)
      racc (~> 1.4)
    pg (1.5.4)
    psych (5.1.2)
      stringio
    puma (6.4.2)
      nio4r (~> 2.0)
    racc (1.7.3)
    rack (3.0.9)
    rack-session (2.0.0)
      rack (>= 3.0.0)
    rack-test (2.1.0)
      rack (>= 1.3)
    rackup (2.1.0)
      rack (>= 3)
      webrick (~> 1.8)
    rails (7.1.3)
      actioncable (= 7.1.3)
      actionmailbox (= 7.1.3)
      actionmailer (= 7.1.3)
      actionpack (= 7.1.3)
      actiontext (= 7.1.3)
      actionview (= 7.1.3)
      activejob (= 7.1.3)
      activemodel (= 7.1.3)
      activerecord (= 7.1.3)
      activestorage (= 7.1.3)
      activesupport (= 7.1.3)
      bundler (>= 1.15.0)
      railties (= 7.1.3)
    rails-dom-testing (2.2.0)
      activesupport (>= 5.0.0)
      minitest
      nokogiri (>= 1.6)
    rails-html-sanitizer (1.6.0)
      loofah (~> 2.21)
      nokogiri (~> 1.14)
    railties (7.1.3)
      actionpack (= 7.1.3)
      activesupport (= 7.1.3)
      irb
      rackup (>= 1.0.0)
      rake (>= 12.2)
      thor (~> 1.0, >= 1.2.2)
      zeitwerk (~> 2.6)
    rake (13.1.0)
    rdoc (6.6.2)
      psych (>= 4.0.0)
    reline (0.4.2)
      io-console (~> 0.5)
    ruby2_keywords (0.0.5)
    stringio (3.1.0)
    thor (1.3.0)
    timeout (0.4.1)
    tzinfo (2.0.6)
      concurrent-ruby (~> 1.0)
    webrick (1.8.1)
    websocket-driver (0.7.6)
      websocket-extensions (>= 0.1.0)
    websocket-extensions (0.1.5)
    zeitwerk (2.6.13)

PLATFORMS
  x86_64-linux

DEPENDENCIES
  bootsnap
  debug
  pg (~> 1.1)
  puma (>= 5.0)
  rails (~> 7.1.3)
  tzinfo-data

RUBY VERSION
   ruby 3.0.0p0

BUNDLED WITH
   2.2.3

Este es mi archivo database.yml:

# PostgreSQL. Versions 9.3 and up are supported.
#
# Install the pg driver:
#   gem install pg
# On macOS with Homebrew:
#   gem install pg -- --with-pg-config=/usr/local/bin/pg_config
# On Windows:
#   gem install pg
#       Choose the win32 build.
#       Install PostgreSQL and put its /bin directory on your path.
#
# Configure Using Gemfile
# gem "pg"
#
default: &default
  adapter: postgresql
  encoding: UTF8
  # For details on connection pooling, see Rails configuration guide
  # https://guides.rubyonrails.org/configuring.html#database-pooling
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: <%= Rails.application.credentials.database[:database] %>
  host: <%= Rails.application.credentials.database[:host] %>
  # name: <%= Rails.application.credentials.database[:name] %>
  username: <%= Rails.application.credentials.database[:username] %>
  password: <%= Rails.application.credentials.database[:password] %>


  # The specified database role being used to connect to PostgreSQL.
  # To create additional roles in PostgreSQL see `$ createuser --help`.
  # When left blank, PostgreSQL will use the default role. This is
  # the same name as the operating system user running Rails.
  #username: rails_app

  # The password associated with the PostgreSQL role (username).
  #password:

  # Connect on a TCP socket. Omitted by default since the client uses a
  # domain socket that doesn't need configuration. Windows does not have
  # domain sockets, so uncomment these lines.
  #host: localhost

  # The TCP port the server listens on. Defaults to 5432.
  # If your server runs on a different port number, change accordingly.
  #port: 5432

  # Schema search path. The server defaults to $user,public
  #schema_search_path: myapp,sharedapp,public

  # Minimum log levels, in increasing order:
  #   debug5, debug4, debug3, debug2, debug1,
  #   log, notice, warning, error, fatal, and panic
  # Defaults to warning.
  #min_messages: notice

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: <%= Rails.application.credentials.database[:database] %>
  host: <%= Rails.application.credentials.database[:host] %>
  # name: <%= Rails.application.credentials.database[:name] %>
  username: <%= Rails.application.credentials.database[:username] %>
  password: <%= Rails.application.credentials.database[:password] %>


# As with config/credentials.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password or a full connection URL as an environment
# variable when you boot the app. For example:
#
#   DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
#
# If the connection URL is provided in the special DATABASE_URL environment
# variable, Rails will automatically merge its configuration values on top of
# the values provided in this file. Alternatively, you can specify a connection
# URL environment variable explicitly:
#
#   production:
#     url: <%= ENV["MY_APP_DATABASE_URL"] %>
#
# Read https://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full overview on how database connection configuration can be specified.
#
production:
  <<: *default
  database: <%= Rails.application.credentials.database[:database] %>
  host: <%= Rails.application.credentials.database[:host] %>
  # name: <%= Rails.application.credentials.database[:name] %>
  username: <%= Rails.application.credentials.database[:username] %>
  password: <%= Rails.application.credentials.database[:password] %>

Cuando entro a la console de rails y ejecuto

Rails.application.credentials.database

me muestra mis credenciales correctamente

Estoy usando Ubuntu 23.10

Al hacer rails db:create me aparece el siguiente error:

/home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/pg-1.5.4/lib/pg/connection.rb:690: [BUG] Segmentation fault at 0x00007f74e993e140
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux]

(un montón de líneas de control frame information)

4ee5c2000-7f74ee5c3000 r--p 00000000 08:05 1442171                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f74ee5c3000-7f74ee5ed000 r-xp 00001000 08:05 1442171                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f74ee5ed000-7f74ee5f7000 r--p 0002b000 08:05 1442171                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f74ee5f7000-7f74ee5f9000 r--p 00035000 08:05 1442171                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7f74ee5f9000-7f74ee5fb000 rw-p 00037000 08:05 1442171                    /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
7ffc1f7eb000-7ffc1ffea000 rw-p 00000000 00:00 0                          [stack]
7ffc1fff1000-7ffc1fff5000 r--p 00000000 00:00 0                          [vvar]
7ffc1fff5000-7ffc1fff7000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]


Aborted (core dumped)

5
  • En tu archivo database.yml , no veo la información de tu bd postgresql
    – Jorgesys
    Commented el 13 feb. a las 15:44
  • @Jorgesys ya coloqué el codigo del archivo database.yml
    – Jesus Diaz
    Commented el 13 feb. a las 18:21
  • el error es un "stack overflow", veo que existe la bd y está configurada, ya que mencionas obtuviste las credenciales, Prueba inicialmente actualizar las gemas con "bundle update"
    – Jorgesys
    Commented el 13 feb. a las 20:51
  • @Jorgesys Ya he hecho eso, al igual que desinstalar y volver a instalar ruby. Estoy usando rvm, y para poder instalar ruby 3.0.0, necesito hacerlo con openssl, porque de lo contrario no logro instalarlo, no se si eso tenga algo que ver
    – Jesus Diaz
    Commented el 13 feb. a las 22:32
  • Ok el problema entonces solo es de sincronización, lo que provoca un error "stack overflow" como indica el error. Voy a agregar una respuesta.
    – Jorgesys
    Commented el 14 feb. a las 15:01

2 respuestas 2

1

El error desapareció al instalar ruby 3.1.2 con asdf en vez de hacerlo con rvm

0

El problema se indica aquí:

#<Thread:0x00005648c3de4e20@puma srv tp 002 /home/jesusdicen/.rvm/gems/ruby-3.0.0/gems/puma-6.4.2/lib/puma/thread_pool.rb:113 sleep> terminated with exception (report_on_exception is true): migration.rb:641:in `synchronize': machine stack overflow in critical region (fatal)

es un problema de sincronización el que causa el desbordamiento de pila.

De acuerdo a lo que comentas la base de datos existe y tus credenciales son correctas, te sugiero cambiar dentro de tu archivo database.yml el número de threads que usara el Worker de Puma, esto para asegurar que usas 5, define fijo 5 y prueba nuevamente.

default: &default
  adapter: postgresql
  encoding: UTF8
  pool: 5

  # For details on connection pooling, see Rails configuration guide
  # https://guides.rubyonrails.org/configuring.html#database-pooling
  #pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

en la seccion "development", te sugiero también definas los datos ahí mismo, escribiendo los valores directamente, para asegurar que no tengas un problema al definir una valor de base de datos, username, password etc incorrecto:

development:
  database: ????
  host: ????
  username: ????
  password: ????
3
  • Me sigue dando el mismo error de synchronize. Además, cuando ejecuto en la terminal el comando rails db:migrate:up VERSION=1 me da un error de core dumped
    – Jesus Diaz
    Commented el 14 feb. a las 17:55
  • mmmm me parece que entonces hay algo en las dependencias, podrías agregar el error completo que te aparece que indica " (core dumped)"
    – Jorgesys
    Commented el 14 feb. a las 19:08
  • listo. El error de cored dumped es bastante extenso, solo coloqué lo que aparece al inicio y al final
    – Jesus Diaz
    Commented el 14 feb. a las 20:31

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge you have read our privacy policy.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.