{"record":{"id":"1363093235dd9d19","repo":"prestodb/presto","slug":"sparkconf-is-already-initialized","errorCode":null,"errorMessage":"SparkConf is already initialized","messagePattern":"SparkConf is already initialized","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-spark-classloader-interface/src/main/java/com/facebook/presto/spark/classloader_interface/PrestoSparkConfInitializer.java","lineNumber":28,"sourceCode":" * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\npackage com.facebook.presto.spark.classloader_interface;\n\nimport org.apache.spark.SparkConf;\nimport org.apache.spark.SparkContext;\n\npublic class PrestoSparkConfInitializer\n{\n    private static final String INITIALIZED_MARKER = \"presto.spark.conf.initialized\";\n\n    private PrestoSparkConfInitializer() {}\n\n    public static void initialize(SparkConf sparkConf)\n    {\n        if (sparkConf.get(INITIALIZED_MARKER, null) != null) {\n            throw new IllegalArgumentException(\"SparkConf is already initialized\");\n        }\n        registerKryoClasses(sparkConf);\n        sparkConf.set(INITIALIZED_MARKER, \"true\");\n    }\n\n    private static void registerKryoClasses(SparkConf sparkConf)\n    {\n        sparkConf.registerKryoClasses(new Class[] {\n                MutablePartitionId.class,\n                PrestoSparkMutableRow.class,\n                PrestoSparkSerializedPage.class,\n                SerializedPrestoSparkTaskDescriptor.class,\n                SerializedTaskInfo.class,\n                PrestoSparkShuffleStats.class,\n                PrestoSparkStorageHandle.class,\n                SerializedPrestoSparkTaskSource.class\n        });\n    }","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-spark-classloader-interface/src/main/java/com/facebook/presto/spark/classloader_interface/PrestoSparkConfInitializer.java#L10-L46","documentation":"PrestoSparkConfInitializer.initialize registers required Kryo classes and stamps an INITIALIZED_MARKER into the SparkConf. If the marker is already present, the conf was initialized more than once, and initialize throws IllegalArgumentException to prevent duplicate Kryo registrations.","triggerScenarios":"Calling PrestoSparkConfInitializer.initialize on the same SparkConf instance twice, or on a conf that was already stamped (e.g. shared between driver tasks or a retry path).","commonSituations":"Application bootstrap code that re-runs initialization after a failed launch; copy/reuse of a SparkConf across multiple SparkContext creations; duplicate plugin/launcher invocation.","solutions":["Call initialize exactly once per SparkConf before creating the SparkContext","Create a fresh SparkConf instead of re-initializing an existing one","Guard with a check of sparkConf.get(INITIALIZED_MARKER) before calling initialize"],"exampleFix":"// before\nPrestoSparkConfInitializer.initialize(sparkConf);\nPrestoSparkConfInitializer.initialize(sparkConf);\n// after\nPrestoSparkConfInitializer.initialize(sparkConf); // once only, then reuse","handlingStrategy":"validation","validationCode":"if (sparkConf.get(\"__presto_conf_initialized__\", null) == null) { PrestoSparkConfInitializer.initialize(sparkConf); }","typeGuard":null,"tryCatchPattern":"try { PrestoSparkConfInitializer.initialize(sparkConf); } catch (IllegalArgumentException e) { /* already initialized: safe to proceed */ }","preventionTips":["Call initialize exactly once per SparkConf at a single well-known bootstrap point","Do not re-run launcher/bootstrap code on an existing conf","Create a fresh SparkConf for each launch attempt"],"tags":["java","spark","configuration","initialization"],"backgroundTag":"duplicate-initialization","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}