Skip to content

[WIP] Add @volatile to SparkSession instance for thread safety#22

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/add-volatile-to-spark-session
Open

[WIP] Add @volatile to SparkSession instance for thread safety#22
Copilot wants to merge 1 commit into
mainfrom
copilot/add-volatile-to-spark-session

Conversation

Copilot AI commented Apr 16, 2026

Copy link
Copy Markdown

Thanks for asking me to work on this. I will get started on it and keep this PR's description up to date as I form a plan and make progress.


This section details on the original issue you should resolve

<issue_title>SparkFactory: doble-checked locking sin @volatile</issue_title>
<issue_description>SparkFactory: doble-checked locking sin @volatile

El singleton de SparkSession usa doble-checked locking pero instance no es @volatile. En la JVM, el modelo de memoria (JMM) no garantiza que una escritura en un thread sea visible en otro sin una barrera de memoria. Resultado: dos threads podrían pasar el primer if (instance == null) simultáneamente y crear dos SparkSessions.</issue_description>

<agent_instructions>Agregar @volatile a la declaración de instance

Con @volatile, la JVM garantiza visibilidad inmediata entre threads. El synchronized protege la sección crítica y @volatile garantiza que el resultado sea visible. Alternativa más limpia: usar lazy val de Scala que ya es thread-safe por diseño.</agent_instructions>

Comments on the Issue (you are @copilot in this section)

Copilot AI linked an issue Apr 16, 2026 that may be closed by this pull request
@federicopfund federicopfund marked this pull request as ready for review April 16, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SparkFactory: doble-checked locking sin @volatile

2 participants