{"record":{"id":"534c441df91248dc","repo":"hashicorp/nomad","slug":"launch-insert-failed-v","errorCode":null,"errorMessage":"launch insert failed: %v","messagePattern":"launch insert failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":3361,"sourceCode":"\n\t// Check if the job already exists\n\texisting, err := txn.First(\"periodic_launch\", \"id\", launch.Namespace, launch.ID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"periodic launch lookup failed: %v\", err)\n\t}\n\n\t// Setup the indexes correctly\n\tif existing != nil {\n\t\tlaunch.CreateIndex = existing.(*structs.PeriodicLaunch).CreateIndex\n\t\tlaunch.ModifyIndex = index\n\t} else {\n\t\tlaunch.CreateIndex = index\n\t\tlaunch.ModifyIndex = index\n\t}\n\n\t// Insert the job\n\tif err := txn.Insert(\"periodic_launch\", launch); err != nil {\n\t\treturn fmt.Errorf(\"launch insert failed: %v\", err)\n\t}\n\tif err := txn.Insert(\"index\", &IndexEntry{\"periodic_launch\", index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %v\", err)\n\t}\n\n\treturn txn.Commit()\n}\n\n// DeletePeriodicLaunch is used to delete the periodic launch\nfunc (s *StateStore) DeletePeriodicLaunch(index uint64, namespace, jobID string) error {\n\ttxn := s.db.WriteTxn(index)\n\tdefer txn.Abort()\n\n\terr := s.DeletePeriodicLaunchTxn(index, namespace, jobID, txn)\n\tif err == nil {\n\t\treturn txn.Commit()\n\t}\n\treturn err","sourceCodeStart":3343,"sourceCodeEnd":3379,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L3343-L3379","documentation":"UpsertPeriodicLaunch writes the PeriodicLaunch record via txn.Insert(\"periodic_launch\", launch); failure returns this error and aborts the transaction, so the periodic job's launch bookkeeping is not persisted and the job may be launched again on the next tick. Insert failures usually mean the object violates the table's index schema or memdb is corrupt.","triggerScenarios":"Periodic job evaluation/launch where txn.Insert of the PeriodicLaunch struct fails — e.g. missing Namespace or ID fields required by the \"id\" index.","commonSituations":"Launch records missing namespace after upgrade from pre-0.8-style state, corrupted job objects, or version-skewed servers.","solutions":["Verify the PeriodicLaunch has valid Namespace and ID before insertion.","Inspect the wrapped error for the memdb schema complaint.","Restart the server agent and let leadership re-election replay state from Raft.","Upgrade/downgrade so all servers run the same Nomad version."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"func validLaunch(l *structs.PeriodicLaunch) error {\n    if l == nil || l.ID == \"\" || l.Namespace == \"\" {\n        return errors.New(\"periodic launch requires non-empty ID and Namespace\")\n    }\n    return nil\n}\nif err := validLaunch(launch); err != nil { return err }\nreturn store.UpsertPeriodicLaunch(index, launch)","typeGuard":"func validLaunch(l *structs.PeriodicLaunch) bool {\n    return l != nil && l.ID != \"\" && l.Namespace != \"\"\n}","tryCatchPattern":"if err := store.UpsertPeriodicLaunch(index, launch); err != nil {\n    if strings.Contains(err.Error(), \"launch insert failed\") {\n        // txn aborted; the job will be launched again on the next tick\n        log.Warn(\"periodic launch not persisted; will retry next tick\", \"err\", err)\n        return err\n    }\n    return err\n}","preventionTips":["Ensure Namespace/ID are populated on PeriodicLaunch (especially after upgrades from pre-namespace versions)","Accept duplicate launches on next tick as the built-in recovery path","Keep all servers on the same Nomad version","Restart the leader if insert errors repeat"],"tags":["nomad","state-store","periodic-job","insert-failed"],"backgroundTag":"memdb-insert-failed","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}