apache / apache/parquet-java

Thread safety bug in CodecFactory

Aperta
#2,669 9 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Component: Java Component: Parquet Priority: Major Type: bug
Lingua principale
Java
Stelle
3.1k
Fork
1.6k
Merge medio
3g 12h
PR unite (30g)
33

Descrizione

The code for returning Compressor objects to the caller goes to some lengths to achieve thread safety, including keeping Codec objects in an Apache Commons pool that has thread-safe borrow semantics.  This is all undone by the BytesCompressor and BytesDecompressor Maps in org.apache.parquet.hadoop.CodecFactory which end up caching single compressor and decompressor instances due to code in CodecFactory@getCompressor and CodecFactory@getDecompressor.  When the caller runs multiple threads, those threads end up sharing compressor and decompressor instances.

For compressors based on Xerial Snappy this bug has no effect because that library is itself thread safe.  But when BuiltInGzipCompressor from Hadoop is selected for the CompressionCodecName.GZIP case, serious problems ensue.  That class is not thread safe and sharing one instance of it between threads produces both silent data corruption and JVM crashes.

To fix this situation, parquet-mr should stop caching single compressor and decompressor instances.

**Reporter**: [James Turton](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=dzamo)
#### Related issues:
- [Parquet CodecFactory thread safety bug](https://issues.apache.org/jira/browse/DRILL-8139) (fixes)

**Note**: *This issue was originally created as [PARQUET-2126](https://issues.apache.org/jira/browse/PARQUET-2126). Please see the [migration documentation](https://issues.apache.org/jira/browse/PARQUET-2502) for further details.*

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia da org.apache.parquet.hadoop.CodecFactory, in particolare da getCompressor e getDecompressor, e traccia il modo in cui le mappe BytesCompressor e BytesDecompressor interagiscono con Apache Commons pool. Il lavoro è completato quando le istanze di compressor e decompressor non sono più memorizzate nella cache come singole istanze condivise, così i chiamanti GZIP concorrenti non possono condividere il BuiltInGzipCompressor non thread-safe.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
java
Ambito
backend
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Specificata chiaramente
Idoneità per principianti
42/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.