Skip to content

Conversation

@lw-lin
Copy link
Contributor

@lw-lin lw-lin commented Jan 17, 2016

Currently ParquetOutputFormat.getRecordWriter() contains an unsynchronized lazy initialization of the non-volatile static field memoryManager.

Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, when ParquetOutputFormat.getRecordWriter() is called by multiple threads.

This PR makes memoryManager volatile to correct the problem.

@lw-lin
Copy link
Contributor Author

lw-lin commented Jan 17, 2016

This is fairly a small change, @rdblue @liancheng would you please take a look at this?
Cheers.

@liancheng
Copy link
Contributor

+1

@julienledem
Copy link
Member

should we not have a synchronized block around the if (memoryManager == null) ... ?

…getMemoryManager()

Adds synchronization around the creation of memoryManager as well as
getMemoryManager()
@lw-lin
Copy link
Contributor Author

lw-lin commented Feb 2, 2016

@julienledem Thanks for reviewing and pointing that out. I think we should have the synchronized block.

The latest commit adds this synchronized block for both memoryManager creation snippet and getMemoryManager() method.

Would you take another look please? Thanks!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

volatile is not needed anymore

@julienledem
Copy link
Member

+1

@asfgit asfgit closed this in 944291b Feb 16, 2016
piyushnarang pushed a commit to piyushnarang/parquet-mr that referenced this pull request Jun 15, 2016
Currently ParquetOutputFormat.getRecordWriter() contains an unsynchronized lazy initialization of the non-volatile static field *memoryManager*.

Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, when ParquetOutputFormat.getRecordWriter() is called by multiple threads.

This PR makes *memoryManager* volatile to correct the problem.

Author: Liwei Lin <proflin.me@gmail.com>
Author: proflin <proflin.me@gmail.com>

Closes apache#313 from proflin/PARQUET-431 and squashes the following commits:

1aa4a44 [Liwei Lin] empty commit to trigger CI
5e94fa3 [Liwei Lin] Remove the volatile modifier for memoryManager
d54bb99 [Liwei Lin] Undo the Deprecated anotation
fd1df4e [Liwei Lin] Adds synchronization around the creation of memoryManager as well as getMemoryManager()
615aa5a [proflin] PARQUET-431
rdblue pushed a commit to rdblue/parquet-mr that referenced this pull request Jul 13, 2016
Currently ParquetOutputFormat.getRecordWriter() contains an unsynchronized lazy initialization of the non-volatile static field *memoryManager*.

Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, when ParquetOutputFormat.getRecordWriter() is called by multiple threads.

This PR makes *memoryManager* volatile to correct the problem.

Author: Liwei Lin <proflin.me@gmail.com>
Author: proflin <proflin.me@gmail.com>

Closes apache#313 from proflin/PARQUET-431 and squashes the following commits:

1aa4a44 [Liwei Lin] empty commit to trigger CI
5e94fa3 [Liwei Lin] Remove the volatile modifier for memoryManager
d54bb99 [Liwei Lin] Undo the Deprecated anotation
fd1df4e [Liwei Lin] Adds synchronization around the creation of memoryManager as well as getMemoryManager()
615aa5a [proflin] PARQUET-431
rdblue pushed a commit to rdblue/parquet-mr that referenced this pull request Jan 6, 2017
Currently ParquetOutputFormat.getRecordWriter() contains an unsynchronized lazy initialization of the non-volatile static field *memoryManager*.

Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, when ParquetOutputFormat.getRecordWriter() is called by multiple threads.

This PR makes *memoryManager* volatile to correct the problem.

Author: Liwei Lin <proflin.me@gmail.com>
Author: proflin <proflin.me@gmail.com>

Closes apache#313 from proflin/PARQUET-431 and squashes the following commits:

1aa4a44 [Liwei Lin] empty commit to trigger CI
5e94fa3 [Liwei Lin] Remove the volatile modifier for memoryManager
d54bb99 [Liwei Lin] Undo the Deprecated anotation
fd1df4e [Liwei Lin] Adds synchronization around the creation of memoryManager as well as getMemoryManager()
615aa5a [proflin] PARQUET-431
rdblue pushed a commit to rdblue/parquet-mr that referenced this pull request Jan 10, 2017
Currently ParquetOutputFormat.getRecordWriter() contains an unsynchronized lazy initialization of the non-volatile static field *memoryManager*.

Because the compiler or processor may reorder instructions, threads are not guaranteed to see a completely initialized object, when ParquetOutputFormat.getRecordWriter() is called by multiple threads.

This PR makes *memoryManager* volatile to correct the problem.

Author: Liwei Lin <proflin.me@gmail.com>
Author: proflin <proflin.me@gmail.com>

Closes apache#313 from proflin/PARQUET-431 and squashes the following commits:

1aa4a44 [Liwei Lin] empty commit to trigger CI
5e94fa3 [Liwei Lin] Remove the volatile modifier for memoryManager
d54bb99 [Liwei Lin] Undo the Deprecated anotation
fd1df4e [Liwei Lin] Adds synchronization around the creation of memoryManager as well as getMemoryManager()
615aa5a [proflin] PARQUET-431
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.

3 participants