You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2022/02/17 14:59:55 UTC

[GitHub] [drill] vvysotskyi commented on a change in pull request #2463: DRILL-8139: Data corruption and occasional segfaults querying Parquet/gzip under the async column reader and sync page reader

vvysotskyi commented on a change in pull request #2463:
URL: https://github.com/apache/drill/pull/2463#discussion_r809142708



##########
File path: exec/java-exec/src/main/java/org/apache/drill/exec/store/parquet/compression/DrillCompressionCodecFactory.java
##########
@@ -80,38 +99,56 @@ public DrillCompressionCodecFactory(Configuration config, ByteBufferAllocator al
   }
 
   @Override
-  public BytesInputCompressor getCompressor(CompressionCodecName codecName) {
+  public synchronized BytesInputCompressor getCompressor(CompressionCodecName codecName) {
     if (AIRCOMPRESSOR_CODECS.contains(codecName)) {
       return airCompressors.computeIfAbsent(
           codecName,
           c -> new AirliftBytesInputCompressor(codecName, allocator)
       );
+    } else if (codecName != CompressionCodecName.SNAPPY) {
+      // Work around PARQUET-2126: construct a new codec factory every time to
+      // avoid a concurrrency bug c.f. DRILL-8139. Remove once PARQUET-2126 is
+      // fixed.  Snappy is immune because of the thread safety in the Xerial lib.
+      CompressionCodecFactory ccf = CodecFactory.createDirectCodecFactory(config, allocator, pageSize);
+      // hold onto a reference for later release()
+      singleUseFactories.add(ccf);
+      return ccf.getCompressor(codecName);
     } else {
       return parqCodecFactory.getCompressor(codecName);
     }
   }
 
   @Override
-  public BytesInputDecompressor getDecompressor(CompressionCodecName codecName) {
+  public synchronized BytesInputDecompressor getDecompressor(CompressionCodecName codecName) {
     if (AIRCOMPRESSOR_CODECS.contains(codecName)) {
       return airCompressors.computeIfAbsent(
           codecName,
           c -> new AirliftBytesInputCompressor(codecName, allocator)
       );
+    } else if (codecName != CompressionCodecName.SNAPPY) {

Review comment:
       `AIRCOMPRESSOR_CODECS` contains `CompressionCodecName.SNAPPY`, so this condition will be always `true`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@drill.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org