When deploying stateful applications on Kubernetes, managing container restarts is usually straightforward. However, things get complicated when your application pod enters a persistent CrashLoopBackOff not because of a code bug, but due to an underlying data compatibility issue in your storage layer.
In this article, I will walk you through a real-world scenario where a standard microservice setup (Application + MongoDB) crashed after a deployment change, how I traced the root cause to a database version mismatch inside the Persistent Volume Claim (PVC), and how to safely resolve it without losing data.
The Architecture
The setup consists of a classic two-tier application deployed inside a local Kubernetes cluster:
- Application Pod: A standard stateless deployment running a Node.js API backend.
- Database Pod: A standard Kubernetes Deployment running MongoDB.
- Storage: A PersistentVolumeClaim (PVC) mounted to the MongoDB deployment at
/data/dbto ensure database updates persist across pod restarts.
The Symptom: Sudden CrashLoopBackOff
After applying a deployment update intended to upgrade the infrastructure, the system went down. Running kubectl get pods revealed a frustrating cycle:
$ kubectl get pods PS C:\devops-mastered\ai-task-management-system\k8s> kubectl get pods NAME READY STATUS RESTARTS AGE mongo-7884b855cc-2zxtr 1/1 Running 0 3m1s scheduling-test 1/1 Running 3 (2d ago) 27d task-api-8446d7bccc-sgz7w 0/1 CrashLoopBackOff 80 (58s ago) 13d Both the application and the database were failing.
The Investigative Trail
Step 1: Checking the Application Logs
Because the application serves the user requests, I started checking its logs first to see why it was failing its health checks.
kubectl logs task-api-8446d7bccc-sgz7w > ai-task-management-system@1.0.0 dev > nodemon --legacy-watch src/server.js npm error path /app npm error command failed npm error signal SIGTERM npm notice npm notice New major version of npm available! 10.8.2 -> 12.2.1 npm notice Changelog: https://github.com/npm/cli/releases/tag/v12.2.1 npm notice To update run: npm install -g npm@12.2.1 npm error A complete log of this run can be found in: /root/.npm/_logs/2026-10-28T06_04_06_402Z-debug-0.log [nodemon] 3.1.14 [nodemon] to restart at any time, enter `rs` [nodemon] watching path(s): *.* [nodemon] watching extensions: js,mjs,cjs,json [nodemon] starting `node src/server.js` - Log Output: The application logs showed continuous connection timeouts. It was repeatedly attempting to connect to the MongoDB service URI, failing, throwing an unhandled exception, and terminating.
This proved the application itself wasn't broken; its dependency (the database) was missing.
Step 2: Digging into the MongoDB Container Logs
Next, I isolated the core issue by inspecting the database pod's logs.
kubectl logs mongo-7884b855cc-2zxtr {"t":{"$date":"2026-10-26T06:38:14.878+00:00"},"s":"F", "c":"CONTROL", "id":20573, "ctx":"initandlisten","msg":"Wrong mongod version","attr":{"error":"UPGRADE PROBLEM: Found an invalid featureCompatibilityVersion document (ERROR: Location4926900: Invalid featureCompatibilityVersion document in admin.system.version: { _id: \"featureCompatibilityVersion\", version: \"8.2\" }. See https://docs.mongodb.com/master/release-notes/8.0-compatibility/#feature-compatibility. :: caused by :: Invalid feature compatibility version value '8.2'. Expected one of the following versions: ''9.0', '8.3', '8.0'. See https://docs.mongodb.com/master/release-notes/8.0-compatibility/#feature-compatibility.). If the current featureCompatibilityVersion is below 8.0, see the documentation on upgrading at https://docs.mongodb.com/master/release-notes/8.0/#upgrade-procedures."}} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"REPL", "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":15000}} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"REPL", "id":4794602, "ctx":"initandlisten","msg":"Attempting to enter quiesce mode"} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"-", "id":6371601, "ctx":"initandlisten","msg":"Shutting down the FLE Crud thread pool"} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"COMMAND", "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"NETWORK", "id":8314100, "ctx":"initandlisten","msg":"Shutdown: Closing listener sockets"} {"t":{"$date":"2026-10-26T06:38:14.879+00:00"},"s":"I", "c":"NETWORK", "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"CONTROL", "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"-", "id":20520, "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"CONTROL", "id":4784908, "ctx":"initandlisten","msg":"Shutting down PeriodicThreadToAbortExpiredTransactions"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"CONTROL", "id":10036707,"ctx":"initandlisten","msg":"Shutting down PeriodicThreadToRollbackUnderCachePressure"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"REPL", "id":4784909, "ctx":"initandlisten","msg":"Shutting down the ReplicationCoordinator"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"SHARDING", "id":4784910, "ctx":"initandlisten","msg":"Shutting down the ShardingInitializationMongoD"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"REPL", "id":4784911, "ctx":"initandlisten","msg":"Enqueuing the ReplicationStateTransitionLock for shutdown"} {"t":{"$date":"2026-10-26T06:38:14.880+00:00"},"s":"I", "c":"REPL", "id":9945003, "ctx":"initandlisten","msg":"Intent Registry killConflictingOperations","attr":{"interrupt":3}} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"REPL", "id":10286300,"ctx":"thread13","msg":"State transition ops metrics for intent registry","attr":{"metrics":{"lastStateTransition":"SHUTDOWN","totalOpsKilledByIntentRegistry":0}}} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"-", "id":4784912, "ctx":"initandlisten","msg":"Killing all operations for shutdown"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"-", "id":4695300, "ctx":"initandlisten","msg":"Interrupted all currently running operations","attr":{"opsKilled":4}} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"COMMAND", "id":4784913, "ctx":"initandlisten","msg":"Shutting down all open transactions"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"REPL", "id":4784914, "ctx":"initandlisten","msg":"Acquiring the ReplicationStateTransitionLock for shutdown"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"INDEX", "id":4784915, "ctx":"initandlisten","msg":"Shutting down the IndexBuildsCoordinator"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"EXECUTOR", "id":11280000,"ctx":"initandlisten","msg":"Starting thread pool","attr":{"poolName":"IndexBuildsCoordinatorMongod","numThreads":0,"minThreads":0,"maxThreads":1000000000}} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"NETWORK", "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"SHARDING", "id":9439300, "ctx":"initandlisten","msg":"Shutting down the filtering metadata cache"} {"t":{"$date":"2026-10-26T06:38:14.881+00:00"},"s":"I", "c":"-", "id":11437200,"ctx":"initandlisten","msg":"Shutting down the ReadWriteConcernDefaults"} {"t":{"$date":"2026-10-26T06:38:14.882+00:00"},"s":"I", "c":"NETWORK", "id":20562, "ctx":"initandlisten","msg":"Shutdown: Closing open transport sessions"} {"t":{"$date":"2026-10-26T06:38:14.882+00:00"},"s":"I", "c":"NETWORK", "id":4784923, "ctx":"initandlisten","msg":"Shutting down the ASIO transport SessionManager"} {"t":{"$date":"2026-10-26T06:38:14.882+00:00"},"s":"I", "c":"CONTROL", "id":4784928, "ctx":"initandlisten","msg":"Shutting down the TTL monitor"} {"t":{"$date":"2026-10-26T06:38:14.882+00:00"},"s":"I", "c":"CONTROL", "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"} {"t":{"$date":"2026-10-26T06:38:14.882+00:00"},"s":"I", "c":"CONTROL", "id":4784930, "ctx":"initandlisten","msg":"Shutting down the storage engine"} {"t":{"$date":"2026-10-26T06:38:14.883+00:00"},"s":"I", "c":"STORAGE", "id":22320, "ctx":"initandlisten","msg":"Shutting down journal flusher thread"} {"t":{"$date":"2026-10-26T06:38:14.883+00:00"},"s":"I", "c":"STORAGE", "id":22321, "ctx":"initandlisten","msg":"Finished shutting down journal flusher thread"} {"t":{"$date":"2026-10-26T06:38:14.884+00:00"},"s":"I", "c":"STORAGE", "id":22322, "ctx":"initandlisten","msg":"Shutting down checkpoint thread"} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"STORAGE", "id":22323, "ctx":"initandlisten","msg":"Finished shutting down checkpoint thread"} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"STORAGE", "id":20282, "ctx":"initandlisten","msg":"Deregistering all the collections"}{"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"STORAGE", "id":10158003,"ctx":"initandlisten","msg":"SpillWiredTigerKVEngine shutting down"} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"STORAGE", "id":10158006,"ctx":"initandlisten","msg":"Closing spill WiredTiger","attr":{"closeConfig":"leak_memory=true,"}} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":886299,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"closing WiredTiger library."}}} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":886500,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"rolling back all running transactions."}}} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":886552,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"closing all running sessions."}}} {"t":{"$date":"2026-10-26T06:38:14.886+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":886647,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"closing some of the internal threads."}}} {"t":{"$date":"2026-10-26T06:38:14.891+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":890995,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"perform final checkpoint and shutting down the global transaction state"}}} {"t":{"$date":"2026-10-26T06:38:14.891+00:00"},"s":"I", "c":"WTCHKPT", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":891200,"thread":"1:0x7193159ae600","session_name":"close_ckpt","category":"WT_VERB_CHECKPOINT","log_id":1000000,"category_id":5,"verbose_level":"INFO","verbose_level_id":0,"msg":"Checkpoint requested at stable timestamp (0, 0)"}}} {"t":{"$date":"2026-10-26T06:38:14.892+00:00"},"s":"I", "c":"WTCHKPT", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":892800,"thread":"1:0x7193159ae600","session_name":"close_ckpt","category":"WT_VERB_CHECKPOINT_PROGRESS","log_id":1000000,"category_id":7,"verbose_level":"INFO","verbose_level_id":0,"msg":"saving checkpoint snapshot min: 2, snapshot max: 2 snapshot count: 0, oldest timestamp: (0, 0) , meta checkpoint timestamp: (0, 0) base write gen: 1"}}} {"t":{"$date":"2026-10-26T06:38:14.911+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":911129,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"shutdown checkpoint has successfully finished and ran for 19 milliseconds"}}} {"t":{"$date":"2026-10-26T06:38:14.911+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":911653,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1493200,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"shutdown was completed successfully and took 25ms, including 0ms for the rollback to stable, and 19ms for the checkpoint."}}} {"t":{"$date":"2026-10-26T06:38:14.911+00:00"},"s":"I", "c":"WTEVICT", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":911779,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_EVICTION","log_id":1000000,"category_id":15,"verbose_level":"INFO","verbose_level_id":0,"msg":"stopping eviction threads"}}} {"t":{"$date":"2026-10-26T06:38:14.911+00:00"},"s":"I", "c":"WTEVICT", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":911921,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_EVICTION","log_id":1000000,"category_id":15,"verbose_level":"INFO","verbose_level_id":0,"msg":"waiting for eviction threads to stop"}}} {"t":{"$date":"2026-10-26T06:38:14.912+00:00"},"s":"I", "c":"WTEVICT", "id":22430, "ctx":"thread14","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":912031,"thread":"1:0x71930696b6c0","session_dhandle_name":"file:WiredTigerHS.wt","session_name":"eviction-server","category":"WT_VERB_EVICTION","log_id":1000000,"category_id":15,"verbose_level":"INFO","verbose_level_id":0,"msg":"eviction thread exiting"}}} {"t":{"$date":"2026-10-26T06:38:14.933+00:00"},"s":"I", "c":"STORAGE", "id":10158007,"ctx":"initandlisten","msg":"Closed spill WiredTiger ","attr":{"durationMillis":47}} {"t":{"$date":"2026-10-26T06:38:14.933+00:00"},"s":"I", "c":"STORAGE", "id":22317, "ctx":"initandlisten","msg":"WiredTigerKVEngine shutting down"} {"t":{"$date":"2026-10-26T06:38:14.933+00:00"},"s":"I", "c":"STORAGE", "id":22318, "ctx":"initandlisten","msg":"Shutting down session sweeper thread"} {"t":{"$date":"2026-10-26T06:38:14.935+00:00"},"s":"I", "c":"STORAGE", "id":22319, "ctx":"initandlisten","msg":"Finished shutting down session sweeper thread"} {"t":{"$date":"2026-10-26T06:38:14.936+00:00"},"s":"I", "c":"STORAGE", "id":4795902, "ctx":"initandlisten","msg":"Closing WiredTiger","attr":{"closeConfig":"leak_memory=true,use_timestamp=false,"}} {"t":{"$date":"2026-10-26T06:38:14.937+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":936875,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"closing WiredTiger library."}}} {"t":{"$date":"2026-10-26T06:38:14.937+00:00"},"s":"I", "c":"WTRECOV", "id":22430, "ctx":"initandlisten","msg":"WiredTiger message","attr":{"message":{"ts_sec":1792996694,"ts_usec":937228,"thread":"1:0x7193159ae600","session_name":"WT_CONNECTION.close","category":"WT_VERB_RECOVERY_PROGRESS","log_id":1000000,"category_id":35,"verbose_level":"INFO","verbose_level_id":0,"msg":"rolling back all running transactions."}}} {"t":{"$dateSource:https://dev.to/sachintatrari/debugging-kubernetes-solving-mongodb-crashloopbackoff-caused-by-pvc-version-mismatches-1hcaRelated posts
find -size -1M Matched Only the Empty File: Size Units in a Camera Clip Cleanup Script
Mastering Background Tasks in Flutter: Efficient Data Sync & UI Updates
Remove a Photo Background in the Browser: An On-Device Model, No Upload
My morning terminal: zoxide jumps, mise runs the project, starship shows context, fzf picks the file
