<?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 OSError: [Errno 107] Transport endpoint is not connected in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/oserror-errno-107-transport-endpoint-is-not-connected/m-p/63267#M32202</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am facing this error when performing write operation in &lt;FONT face="courier new,courier"&gt;foreach()&lt;/FONT&gt; on a dataframe. The piece of code was working fine for over 3 months but started failing since last week.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nihar_ghude_0-1710175215407.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/6608i99BF9D7E8428070B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="nihar_ghude_0-1710175215407.png" alt="nihar_ghude_0-1710175215407.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To give some context, I have a dataframe &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;extract_df&lt;/FONT&gt;&amp;nbsp;which contains 2 columns &lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;xml_full_name&lt;/FONT&gt;&amp;nbsp;and &lt;FONT face="courier new,courier"&gt;content&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I use the below code to write these xmls to the target folder in &lt;STRONG&gt;ADLS&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;extract_df.foreach(write_file)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'&lt;FONT face="courier new,courier"&gt;write_file&lt;/FONT&gt;' is defined as:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;def write_file(row):&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier"&gt;with open(row.extract_path, "wb") as f:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier"&gt;f.write(row.content)&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The notebook also uses spark.write command to write some parquets which is working fine.&lt;/DIV&gt;&lt;DIV&gt;On investigating, I found that this issue could be related to parallelism and as a work around I tried the below:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;for row in extract_df.collect():&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier"&gt;with open(row.extract_path, "wb") as f:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier"&gt;f.write(row.content)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This works which means the connection is fine but parallelism isn't working. However, this can't be used as a fix though as it will bring down the performance.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Anyone here has faced this issue? If this is related to some configuration, any suggestions on what and where I can check. All inputs are welcome.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Mon, 11 Mar 2024 17:26:43 GMT</pubDate>
    <dc:creator>nihar_ghude</dc:creator>
    <dc:date>2024-03-11T17:26:43Z</dc:date>
    <item>
      <title>OSError: [Errno 107] Transport endpoint is not connected</title>
      <link>https://community.databricks.com/t5/data-engineering/oserror-errno-107-transport-endpoint-is-not-connected/m-p/63267#M32202</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am facing this error when performing write operation in &lt;FONT face="courier new,courier"&gt;foreach()&lt;/FONT&gt; on a dataframe. The piece of code was working fine for over 3 months but started failing since last week.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="nihar_ghude_0-1710175215407.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/6608i99BF9D7E8428070B/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="nihar_ghude_0-1710175215407.png" alt="nihar_ghude_0-1710175215407.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;To give some context, I have a dataframe &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;extract_df&lt;/FONT&gt;&amp;nbsp;which contains 2 columns &lt;/SPAN&gt;&lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;xml_full_name&lt;/FONT&gt;&amp;nbsp;and &lt;FONT face="courier new,courier"&gt;content&lt;/FONT&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I use the below code to write these xmls to the target folder in &lt;STRONG&gt;ADLS&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;extract_df.foreach(write_file)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;'&lt;FONT face="courier new,courier"&gt;write_file&lt;/FONT&gt;' is defined as:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;def write_file(row):&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier"&gt;with open(row.extract_path, "wb") as f:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier"&gt;f.write(row.content)&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The notebook also uses spark.write command to write some parquets which is working fine.&lt;/DIV&gt;&lt;DIV&gt;On investigating, I found that this issue could be related to parallelism and as a work around I tried the below:&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV class="lia-indent-padding-left-30px"&gt;&lt;FONT face="courier new,courier"&gt;for row in extract_df.collect():&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-60px"&gt;&lt;FONT face="courier new,courier"&gt;with open(row.extract_path, "wb") as f:&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV class="lia-indent-padding-left-90px"&gt;&lt;FONT face="courier new,courier"&gt;f.write(row.content)&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;This works which means the connection is fine but parallelism isn't working. However, this can't be used as a fix though as it will bring down the performance.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Anyone here has faced this issue? If this is related to some configuration, any suggestions on what and where I can check. All inputs are welcome.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 11 Mar 2024 17:26:43 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/oserror-errno-107-transport-endpoint-is-not-connected/m-p/63267#M32202</guid>
      <dc:creator>nihar_ghude</dc:creator>
      <dc:date>2024-03-11T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: OSError: [Errno 107] Transport endpoint is not connected</title>
      <link>https://community.databricks.com/t5/data-engineering/oserror-errno-107-transport-endpoint-is-not-connected/m-p/63823#M32370</link>
      <description>&lt;P&gt;Thanks for the suggestion. I am not using structured streaming in the code. Not sure, if i can use `foreachBatch()` without it.&lt;/P&gt;&lt;P&gt;I have added a `try` block around the&amp;nbsp;`foreach()`&amp;nbsp;logic and added the&amp;nbsp;`foreachPartition()`&amp;nbsp;logic in an `except` block.&lt;/P&gt;&lt;P&gt;Also, the error resolved itself without any changes from our side. We are still awaiting response from Databricks support as to why the error intermittently appeared.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 11:52:49 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/oserror-errno-107-transport-endpoint-is-not-connected/m-p/63823#M32370</guid>
      <dc:creator>nihar_ghude</dc:creator>
      <dc:date>2024-03-15T11:52:49Z</dc:date>
    </item>
  </channel>
</rss>

