You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Persistent-mysql在Fedora 27数据库迁移时崩溃,Yesod应用启动失败

Troubleshooting Yesod App Crash (ExitFailure -11) & Missing Migrations

Hey there, let's work through this issue step by step. That ExitFailure (-11) error is almost always a segmentation fault—meaning your app is trying to access memory it shouldn't. Combine that with migrations not running, and it looks like the app is crashing before it even gets to the migration step. Here's how to fix this:

1. First, Force Manual Migrations

Let's rule out database schema issues first by running migrations directly:

stack exec -- yesod migrate
  • If this command also crashes, your problem is with database connectivity or migration logic itself.
  • If it succeeds, the issue is likely with the devel server's initialization order or hot-reloading setup.

2. Verify Database Connection Configuration

Double-check your config/settings.yml for any typos or mismatches with your new machine's MySQL setup:

  • Confirm the host, port, username, password, and database name are all correct.
  • Test the connection manually using the MySQL CLI:
    mysql -u your_db_user -p your_db_name
    

Make sure the user has full permissions on the database, and that MySQL is running locally (or accessible remotely if you're using a remote DB).

3. Clear Build Cache & Recompile

New machines often have cached dependencies or compiled artifacts that can cause weird crashes. Let's reset everything:

stack clean --full
stack build --force-dirty

After this, try running stack exec app first (without devel mode) to see if the crash still happens. If it does, the issue is with the app's core initialization, not the devel server.

4. Debug the Segmentation Fault

To get precise details on where the crash is happening, compile with debug symbols and use GDB:

  1. Build with debug flags:
    stack build --ghc-options="-g"
    
  2. Launch the app in GDB:
    stack exec -- gdb $(stack path --local-install-root)/bin/your-app-exe
    
  3. Inside GDB, run the app with run, and when it crashes, type bt to get a backtrace. This will show you exactly which line of code (or dependency) is causing the segfault.

Common culprits here are incompatible versions of database drivers (like persistent-mysql or mysql-haskell) with your new machine's system libraries. Try locking the same dependency versions that worked on your old machine in your stack.yaml.

5. Check App Initialization Logic

Make sure your app isn't trying to query the database before migrations run. Look at your Foundation.hs or Application.hs for any early initialization code that accesses database tables—if those tables don't exist yet, it'll crash immediately, skipping the migration step.

In a standard Yesod setup, your main function should handle migrations before starting the server. Double-check that it looks something like this:

main :: IO ()
main = do
    settings <- loadSettingsArgs
    foundation <- makeFoundation settings
    runMigrationUnsafe foundation
    warpEnv foundation

内容的提问来源于stack exchange,提问作者user9509751

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 10:27:04