<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Issues when adding keystore spark config for pyspark to mongo atlas X.509 connectivity in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/118796#M45715</link>
    <description>&lt;P&gt;Error Messages -&lt;/P&gt;&lt;P&gt;Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not connect to address=(host=mdb7sywh50xhpr.chkweekm4xjq.us-east-1.rds.amazonaws.com)(port=3306)(type=master) : Could not connect to mdb7sywh50xhpr.chkweekm4xjq.us-east-1.rds.amazonaws.com:3306 : readHandshakeRecord&lt;/P&gt;&lt;P&gt;Caused by: java.net.SocketException: Broken pipe (Write failed)&lt;/P&gt;&lt;P&gt;25/05/10 14:19:06 WARN HiveClientImpl: HiveClient got thrift or connection reset exception, destroying client and retrying (13 tries remaining)&lt;/P&gt;&lt;P&gt;Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient&lt;/P&gt;&lt;P&gt;Caused by: javax.jdo.JDOFatalInternalException: Error creating transactional connection factory&lt;/P&gt;&lt;P&gt;Caused by: java.lang.reflect.InvocationTargetException&lt;/P&gt;</description>
    <pubDate>Sun, 11 May 2025 17:07:02 GMT</pubDate>
    <dc:creator>jash281098</dc:creator>
    <dc:date>2025-05-11T17:07:02Z</dc:date>
    <item>
      <title>Issues when adding keystore spark config for pyspark to mongo atlas X.509 connectivity</title>
      <link>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/118774#M45711</link>
      <description>&lt;P&gt;Step followed -&amp;nbsp;&lt;/P&gt;&lt;P&gt;Step1: To add init script that will copy the keystore file in the tmp location.&lt;/P&gt;&lt;P&gt;Step2: To add spark config in cluster advance options -&amp;nbsp;&lt;/P&gt;&lt;P&gt;spark.driver.extraJavaOptions -Djavax.net.ssl.keyStore=/tmp/keystore.jks -Djavax.net.ssl.keyStorePassword=&amp;lt;pass&amp;gt;&lt;BR /&gt;spark.executor.extraJavaOptions -Djavax.net.ssl.keyStore=/tmp/keystore.jks -Djavax.net.ssl.keyStorePassword=&amp;lt;pass&amp;gt;&lt;/P&gt;&lt;P&gt;After doing above configuration the cluster doesn't execute any commands. In log4j driver logs their is a constant error message. What is the recommended way to achieve mongo atlas X.509 connectivity?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Error Could not connect to mdb7sywh50xhpr.chkweekm4xjq.us-east-1.rds.amazonaws.com:3306 : readHandshakeRecord&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 May 2025 01:38:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/118774#M45711</guid>
      <dc:creator>jash281098</dc:creator>
      <dc:date>2025-05-11T01:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Issues when adding keystore spark config for pyspark to mongo atlas X.509 connectivity</title>
      <link>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/118796#M45715</link>
      <description>&lt;P&gt;Error Messages -&lt;/P&gt;&lt;P&gt;Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Could not connect to address=(host=mdb7sywh50xhpr.chkweekm4xjq.us-east-1.rds.amazonaws.com)(port=3306)(type=master) : Could not connect to mdb7sywh50xhpr.chkweekm4xjq.us-east-1.rds.amazonaws.com:3306 : readHandshakeRecord&lt;/P&gt;&lt;P&gt;Caused by: java.net.SocketException: Broken pipe (Write failed)&lt;/P&gt;&lt;P&gt;25/05/10 14:19:06 WARN HiveClientImpl: HiveClient got thrift or connection reset exception, destroying client and retrying (13 tries remaining)&lt;/P&gt;&lt;P&gt;Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient&lt;/P&gt;&lt;P&gt;Caused by: javax.jdo.JDOFatalInternalException: Error creating transactional connection factory&lt;/P&gt;&lt;P&gt;Caused by: java.lang.reflect.InvocationTargetException&lt;/P&gt;</description>
      <pubDate>Sun, 11 May 2025 17:07:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/118796#M45715</guid>
      <dc:creator>jash281098</dc:creator>
      <dc:date>2025-05-11T17:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Issues when adding keystore spark config for pyspark to mongo atlas X.509 connectivity</title>
      <link>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/138483#M50936</link>
      <description>&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;To achieve MongoDB Atlas X.509 connectivity from Databricks using PySpark, the standard keystore configuration may fail due to certificate, configuration, or driver method issues. The recommended approach involves several key steps, including properly setting up certificates and Spark configs, and addressing Databricks-specific requirements for secure cluster communication.&lt;/P&gt;
&lt;H2 id="recommended-steps" class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0 md:text-lg [hr+&amp;amp;]:mt-4"&gt;Recommended Steps&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Ensure that your keystore and truststore files (JKS or PEM) are valid and contain the correct certificates for X.509 authentication.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Both keystore and truststore should be imported using JVM tools (keytool for JKS; openssl for PEM).&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Place the files in a secure and accessible cluster location, such as&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;/tmp/&lt;/CODE&gt;, using an init script at cluster startup.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Use the following Spark configuration options:&lt;/P&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;CODE&gt;spark.driver.extraJavaOptions -Djavax.net.ssl.keyStore=/tmp/keystore.jks -Djavax.net.ssl.keyStorePassword=&amp;lt;password&amp;gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;&lt;CODE&gt;spark.executor.extraJavaOptions -Djavax.net.ssl.keyStore=/tmp/keystore.jks -Djavax.net.ssl.keyStorePassword=&amp;lt;password&amp;gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;For truststore: add&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;-Djavax.net.ssl.trustStore=/tmp/truststore.jks -Djavax.net.ssl.trustStorePassword=&amp;lt;password&amp;gt;&lt;/CODE&gt;, if required.​&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Confirm that the network access in MongoDB Atlas allows connections from your Databricks cluster IP addresses.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Ensure the Atlas database user matches the subject of your client certificate and that the CA certificate is uploaded in Atlas settings.​&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H2 id="common-pitfalls-and-error" class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0 md:text-lg [hr+&amp;amp;]:mt-4"&gt;Common Pitfalls and Error&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;The error&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;readHandshakeRecord&lt;/CODE&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;is usually caused by misconfigured certificates, mismatched distinguished names, or connecting to the wrong port/service (the error references an RDS hostname/port 3306, which is MySQL—not MongoDB Atlas port). Double-check the cluster endpoint and port.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;When using PEM files, some libraries require options like&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;tlsCAFile&lt;/CODE&gt;,&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;CODE&gt;tlsCertificateKeyFile&lt;/CODE&gt;, etc. For Spark, JKS files and the corresponding JVM options are preferred.​&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Make sure your Databricks runtime version and the MongoDB Spark Connector support X.509 and your Java version.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;H2 id="best-practices-checklist" class="mb-2 mt-4 font-display font-semimedium text-base first:mt-0 md:text-lg [hr+&amp;amp;]:mt-4"&gt;Best Practices Checklist&lt;/H2&gt;
&lt;UL class="marker:text-quiet list-disc"&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Validate your keystore/truststore with provided Java tooling.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Mount certificates in all nodes with an init script.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Use correct Spark configs for both driver and executor.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Whitelist Databricks cluster IPs in Atlas Network Access.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI class="py-0 my-0 prose-p:pt-0 prose-p:mb-2 prose-p:my-0 [&amp;amp;&amp;gt;p]:pt-0 [&amp;amp;&amp;gt;p]:mb-2 [&amp;amp;&amp;gt;p]:my-0"&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;Avoid connecting via non-Atlas-hostnames or SQL database ports (such as RDS/MySQL).&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;P class="my-2 [&amp;amp;+p]:mt-4 [&amp;amp;_strong:has(+br)]:inline-block [&amp;amp;_strong:has(+br)]:pb-2"&gt;If these steps do not resolve the issue, review the Spark and cluster logs for specific SSL/TLS errors, and check MongoDB Atlas user and certificate matching rules in the Atlas dashboard and documentation.​&lt;/P&gt;</description>
      <pubDate>Tue, 11 Nov 2025 01:24:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/issues-when-adding-keystore-spark-config-for-pyspark-to-mongo/m-p/138483#M50936</guid>
      <dc:creator>mark_ott</dc:creator>
      <dc:date>2025-11-11T01:24:35Z</dc:date>
    </item>
  </channel>
</rss>

