Skip to content

ParquetProperties.valuesWriterFactory is not thread-safe #3224

@juja0

Description

@juja0

Describe the bug, including details regarding any error messages, version, and platform.

ParquetProperties.valuesWriterFactory defaults to a singleton instance of DefaultValuesWriterFactory.

ParquetOutputFormat.getRecordWriter provides no way of setting/overriding "valuesWriterFactory" in ParquetProperties.Builder so the same singleton instance of DefaultValuesWriterFactory is used every time.

DefaultValuesWriterFactory.initialize dynamically sets the instance field "delegateFactory" to either a v1 or v2 factory.

When writing to multiple parquet files concurrently, with some threads using v1 and others using v2, the actual writer used becomes unpredictable and files get written with an incorrect format.

Potential fix: ParquetProperties.Builder.valuesWriterFactory should not be instantiated to a singleton instance of DefaultValuesWriterFactory. Instead, it should be instantiated to a new instance of DefaultValuesWriterFactory in the constructor of ParquetProperties.Builder

Component(s)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions