<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Seangles</title>
    <description>The latest articles on DEV Community by Seangles (@seangles).</description>
    <link>https://dev.to/seangles</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3780601%2F937fcf38-9492-4e4e-94dc-eea6900e645e.jpg</url>
      <title>DEV Community: Seangles</title>
      <link>https://dev.to/seangles</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/seangles"/>
    <language>en</language>
    <item>
      <title>The 30-Second Death: A Memoir</title>
      <dc:creator>Seangles</dc:creator>
      <pubDate>Mon, 16 Mar 2026 21:58:58 +0000</pubDate>
      <link>https://dev.to/seangles/the-30-second-death-a-memoir-3gc</link>
      <guid>https://dev.to/seangles/the-30-second-death-a-memoir-3gc</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;A true story about a database that died on a schedule, a developer who tried everything, and a CPU security feature nobody told anyone about.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;My database kept dying. Every. Thirty. Seconds.&lt;/p&gt;

&lt;p&gt;Not crashing with an error. Not leaving a note. Just... gone. Exit code 139. No explanation. No apology.&lt;/p&gt;

&lt;p&gt;I checked the logs. MongoDB had started successfully. Recovered from the previous unclean shutdown. Accepted connections. Everything looked fine.&lt;/p&gt;

&lt;p&gt;Then it died.&lt;/p&gt;




&lt;h2&gt;
  
  
  Act I: Blame the Obvious Thing
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; Why is the DB crashing?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB:&lt;/strong&gt; &lt;em&gt;dies&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Me:&lt;/strong&gt; Okay, unclean shutdown, probably just needs to recover—&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB:&lt;/strong&gt; &lt;em&gt;recovers successfully, then dies again&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;I did what any reasonable engineer does. I blamed the obvious thing.&lt;/p&gt;

&lt;p&gt;"It's &lt;code&gt;mongo:latest&lt;/code&gt;," I said confidently. "Never trust &lt;code&gt;latest&lt;/code&gt;." I pinned the version. &lt;code&gt;mongo:8.0.14-noble&lt;/code&gt;. Stable. Specific. Professional.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mongo:8.0.14-noble&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MongoDB:&lt;/strong&gt; &lt;em&gt;dies at exactly 30 seconds&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Act II: Disable Everything
&lt;/h2&gt;

&lt;p&gt;Fine. The diagnostics collector — FTDC. It reads &lt;code&gt;/proc&lt;/code&gt; files in the background. Kernel 6.19 is brand new. Maybe something changed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;command&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mongod --setParameter diagnosticDataCollectionEnabled=false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MongoDB:&lt;/strong&gt; &lt;em&gt;dies at exactly 30 seconds&lt;/em&gt;&lt;/p&gt;




&lt;p&gt;Seccomp, then. Docker's syscall filter. A classic gotcha. I ran the container with &lt;code&gt;--security-opt seccomp=unconfined&lt;/code&gt;, essentially handing it a skeleton key to the entire kernel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB:&lt;/strong&gt; &lt;em&gt;dies at exactly 30 seconds&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The audacity.&lt;/p&gt;




&lt;h2&gt;
  
  
  Act III: The Nuclear Option
&lt;/h2&gt;

&lt;p&gt;At this point I had one move left: &lt;code&gt;mongo:7&lt;/code&gt;. Downgrade. Accept defeat. Move on with my life.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;mongo:7&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;MongoDB 7:&lt;/strong&gt; &lt;em&gt;reads the data files MongoDB 8 wrote&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB 7:&lt;/strong&gt; these are not my files&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MongoDB 7:&lt;/strong&gt; &lt;em&gt;exits with code 62&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Two databases. Zero working. Outstanding.&lt;/p&gt;




&lt;h2&gt;
  
  
  Act IV: The Internet Knows
&lt;/h2&gt;

&lt;p&gt;I went searching. I found &lt;a href="https://github.com/Sky1-Linux/linux-sky1/issues/15" rel="noopener noreferrer"&gt;a GitHub issue&lt;/a&gt; titled:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"[arm64] MongoDB 8.x crashes ~30s after startup on 6.19.0-sky1-latest.r5"&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;ARM64. I am on x86_64. I kept reading anyway.&lt;/p&gt;

&lt;p&gt;Then, buried in &lt;a href="https://www.findbugzero.com/operational-defect-database/vendors/mongodb/defects/3392546" rel="noopener noreferrer"&gt;a bug report&lt;/a&gt;, the answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"SIGSEGV exactly 30s after start on AMD Zen 5 due to hardware Shadow Stacks (user_shstk) clashing with coroutines."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  The Actual Explanation (I Promise It Makes Sense)
&lt;/h2&gt;

&lt;p&gt;Let me walk you through what actually happened here, because I need you to appreciate the full chain of events.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Intel&lt;/strong&gt; invented a security feature called &lt;strong&gt;Control-flow Enforcement Technology (CET)&lt;/strong&gt;. The idea: add a second, hardware-enforced call stack that runs in parallel with the normal one. Every time a function returns, the CPU checks that the return address matches what the shadow stack recorded. Exploits that hijack return addresses — like ROP chains — get caught at the hardware level before they can do anything. It's genuinely clever engineering.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;AMD&lt;/strong&gt; implemented it too, under the name &lt;strong&gt;Shadow Stacks&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linux kernel 6.19&lt;/strong&gt; decided to &lt;strong&gt;enable it by default&lt;/strong&gt; for user processes.&lt;/p&gt;

&lt;p&gt;Now. &lt;strong&gt;MongoDB 8.0&lt;/strong&gt; uses coroutines. Coroutines do context switching by manually swapping stack pointers — they save the current stack state and jump to a different one. This is a completely normal thing coroutines do.&lt;/p&gt;

&lt;p&gt;The shadow stack looked at this manual stack swap and said:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;"That return address does not match what I recorded. This is a security violation."&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then it fired a &lt;code&gt;SIGSEGV&lt;/code&gt;. Signal 11. Exit code 139.&lt;/p&gt;

&lt;p&gt;After exactly 30 seconds — the interval at which MongoDB's coroutine scheduler runs a particular background task.&lt;/p&gt;

&lt;p&gt;Every time. Like clockwork.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;One line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;GLIBC_TUNABLES&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;glibc.cpu.hwcaps=-SHSTK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tells glibc to disable Shadow Stacks for the process before it starts. MongoDB's coroutines do their stack swaps unmolested. The database lives.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Status: running, ExitCode: 0, Restarts: 0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Post-Mortem
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Time spent&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;too long&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Lines of code changed&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Red herrings investigated&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;mongo:latest&lt;/code&gt; tag, FTDC, Docker seccomp, data file incompatibility&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Actual cause&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;AMD Zen 5 + Linux 6.19 + CET Shadow Stacks + MongoDB coroutines&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;What I should have searched first&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;literally anything other than what I searched&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Takeaway
&lt;/h2&gt;

&lt;p&gt;If you're running &lt;strong&gt;MongoDB 8.0&lt;/strong&gt; in Docker on a &lt;strong&gt;Linux 6.19+ kernel&lt;/strong&gt; with a &lt;strong&gt;newer AMD CPU&lt;/strong&gt; and your container dies silently every ~30 seconds with exit code 139 — this is your fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;GLIBC_TUNABLES&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;glibc.cpu.hwcaps=-SHSTK&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You're welcome. I suffered so you don't have to.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Dedicated to everyone who has ever watched a container die on a 30-second interval and felt their personality change. Yes the article is written with the help of an LLM. I spent too much time on this already, it's genuinely one of the weirdest issues of the month that I faced :p&lt;/em&gt;&lt;/p&gt;

</description>
      <category>mongodb</category>
      <category>linux</category>
      <category>devops</category>
      <category>database</category>
    </item>
  </channel>
</rss>
