Repository navigation
Closed
Description
I encountered the following error (the full traceback is further down):
OSError: Could not open Parquet input source 'oss-shared-scratch/timeseries.parquet/_metadata': Couldn't deserialize thrift: MaxMessageSize reachedwhen reading in a Parquet dataset on S3 with a large _metadata file. In this particular case the _metadata file was 676.5 MB. Based on the error message it looks like this _metadata file is too big for pyarrow to parse.
cc @jorisvandenbossche @rjzamora
Full traceback:
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<timed exec> in <module>
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/dask/dataframe/io/parquet/core.py in read_parquet(path, columns, filters, categories, index, storage_options, engine, gather_statistics, split_row_groups, read_from_paths, chunksize, aggregate_files, **kwargs)
314 gather_statistics = True
315
--> 316 read_metadata_result = engine.read_metadata(
317 fs,
318 paths,
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/dask/dataframe/io/parquet/arrow.py in read_metadata(cls, fs, paths, categories, index, gather_statistics, filters, split_row_groups, read_from_paths, chunksize, aggregate_files, **kwargs)
540 split_row_groups,
541 gather_statistics,
--> 542 ) = cls._gather_metadata(
543 paths,
544 fs,
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/dask/dataframe/io/parquet/arrow.py in _gather_metadata(cls, paths, fs, split_row_groups, gather_statistics, filters, index, dataset_kwargs)
1038 if fs.exists(meta_path):
1039 # Use _metadata file
-> 1040 ds = pa_ds.parquet_dataset(
1041 meta_path,
1042 filesystem=fs,
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/pyarrow/dataset.py in parquet_dataset(metadata_path, schema, filesystem, format, partitioning, partition_base_dir)
492 )
493
--> 494 factory = ParquetDatasetFactory(
495 metadata_path, filesystem, format, options=options)
496 return factory.finish(schema)
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/pyarrow/_dataset.pyx in pyarrow._dataset.ParquetDatasetFactory.__init__()
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/pyarrow/error.pxi in pyarrow.lib.pyarrow_internal_check_status()
~/mambaforge/envs/coiled-jrbourbeau-parquet-demo/lib/python3.9/site-packages/pyarrow/error.pxi in pyarrow.lib.check_status()
OSError: Could not open Parquet input source 'oss-shared-scratch/timeseries.parquet/_metadata': Couldn't deserialize thrift: MaxMessageSize reached
Activity
mrocklin commentedon Aug 12, 2021
Also, we should probably make it optional to even read this file. I think that in @jrbourbeau 's case this resulted in him downloading a 600MB file every time. We should consider a
read_metadata_file=Truekeyword that can be set to False. Currently there is no way to turn this off.jrbourbeau commentedon Aug 12, 2021
Thanks for the additional context @mrocklin. I was going to open a separate issue for that, but as it's also related to the large
_metadatafile, here is a good place for that discussion too.I should also point out that based on the description of
gather_statisticsdask/dask/dataframe/io/parquet/core.py
Lines 174 to 178 in 8d6f2da
FWIW I thought setting
gather_statistics=Falsewould result in us not reading the_metadatafile, but that turned out to not be the case (at least for thepyarrow-datasetandfastparquetengines)mrocklin commentedon Aug 12, 2021
Separate issue sounds good to me.
jrbourbeau commentedon Aug 12, 2021
xref #8030
jorisvandenbossche commentedon Aug 13, 2021
And the metadata file itself was produced by pyarrow? (or did it come from somewhere else?)
mrocklin commentedon Aug 17, 2021
@jorisvandenbossche given @jrbourbeau 's comment in the meta-issue here #8031 I suspect that this was done with the pyarrow-dataset engine. James would know for sure though.
jorisvandenbossche commentedon Aug 17, 2021
Would it be possible to put the offending file on a public bucket (or somewhere else publicly accessible)?
And the code that was used to create the file, is this the code in #8031? (to have a reproducible code example)
jrbourbeau commentedon Aug 18, 2021
Good question. I'm not sure certain as, IIRC, I was running into #7977 when using the
pyarrow-dataasetengine, so I switched tofastparquet. I ended up deleting the_metadatafile as a temporary workaround which, with hindsight, wasn't the wisest decision. I'll try to reproduce in a public bucket and will report backjrbourbeau commentedon Aug 18, 2021
Indeed I ran into issues writing a large dataset using the
pyarrow-datasetengine and switched tofastparquet(for writing). Below is the code snippet used the create the parquet datasetI'm able to reproduce the
error when attempting to read the dataset using the
pyarrow-datasetengine:I'll make that bucket publicly accessible in AWS us-east-1 tomorrow 👍
EDIT:
s3://james-scratch/timeseries-public.parquet/_metadatashould now be publicly accessible (let me know if it isn't)jorisvandenbossche commentedon Aug 18, 2021
@jrbourbeau thanks for the reproducer!
I downloaded the file to check locally, and I can reproduce the error with pyarrow 4.0 and 5.0, but it does work with my local development install:
vs
Now, I don't really know what's the reason for this difference (I don't think it's "fixed", as it also fails with a nightly package). I am not very familiar with thrift, but there might be some config/build options that influence this.
jorisvandenbossche commentedon Aug 18, 2021
OK, so indeed this is related to the thrift version. In my local development environment, I still had libthrift 0.13, with which it works fine as mentioned above. But the latest releases of pyarrow on conda-forge are build with libthrift 0.14. Creating a new local environment with thrift 0.14 and building master of pyarrow with that, I also get the error.
It seems that Apache Thrift introduced a
MaxMessageSizeconfiguration option (https://github.com/apache/thrift/blob/master/doc/specs/thrift-tconfiguration.md#maxmessagesize) in version 0.14 (https://issues.apache.org/jira/browse/THRIFT-5237).Fastparquet uses the python bindings of thrift, and it seems that is still at version 0.13 and not yet updated to 0.14 (https://github.com/conda-forge/thrift-feedstock/). So I suppose this is the reason that the file could be created with the fastparquet engine.
If you have an environment with Arrow built against libthrift 0.13, the file can be read fine. But, with conda-forge, the recent releases are built against 0.14, and you can only get pyarrow 3.0 or lower with libthrift=0.13.
I opened https://issues.apache.org/jira/browse/ARROW-13655 on the Arrow side. I suppose we could expose this configuration option on the Arrow side (but that's not a short-term workaround).
mrocklin commentedon Aug 18, 2021
Nogbit commentedon Sep 3, 2021
@jorisvandenbossche any idea on a workaround? I just ran into this myself with a 700MB metadata file using Dask with Pyarrow 5 to create and read the metadata. Now I can't read it with Dask in my cluster. I'm thinking a custom container with older versions etc, but that's a chore of course (using default image from the Dask helm chart right now).
jrbourbeau commentedon Sep 3, 2021
FYI, I think @jorisvandenbossche is on vacation for a few more days. The
dask=2021.08.1release added aignore_metadata_file=keyword argument toread_parquetwhich can be used to bypass reading the global_metadatafile altogether. That may be useful for working around the thriftMaxMessageSizeissueNogbit commentedon Sep 3, 2021
Fantastic, I will give that try
Nogbit commentedon Sep 3, 2021
Not going too well. I have over 100K parquet files, that metadata file seems pretty essential. I run into this now #4701 as a
df = dd.read_parquet()takes forever, with zero activity on the dashboard (workers sit there doing nothing). Looks like I might have to rebuild my parquet files with a different engine.jrbourbeau commentedon Sep 3, 2021
Ah, I see. Could you try setting
gather_statistics=Falsetoo then?Also wanted to point out that there is some ongoing work to improve reading parquet metadata in parallel over in #8072
Nogbit commentedon Sep 3, 2021
Isn't that param ignored if also ignoring metadata file? Here is what I tried...(with and without inferdivisions)
Nogbit commentedon Sep 3, 2021
I tried what you suggested, same problem.
I recreated it all with
fastparquetas well, and have the same issue on the read side of things with it stalling and nothing happening (metadata file is 1GB). Though here, my notebook kernel auto restarts after 8min.jorisvandenbossche commentedon Sep 9, 2021
Unfortunately there is no direct workaround (if needing to read the actual file), except for using an older thrift version. But the built packages (both wheels and conda-forge, I think) of recent pyarrow versions include the latest thrift, so that might mean building (py)arrow yourself ..
I hope we can fix this on the pyarrow side for the next release (https://issues.apache.org/jira/browse/ARROW-13655), but so that's not a short-term fix.
jorisvandenbossche commentedon Sep 9, 2021
Although it seems that some old builds of arrow-cpp 4.0 still use libthrift 0.13 on conda-forge (testing it with
mamba create -n test python=3.9 pyarrow libthrift=0.13seems to give pyarrow 3.0, though)jorisvandenbossche commentedon Sep 14, 2021
Small update: we have a PR to fix this for the next pyarrow release (apache/arrow#11123, thanks to Antoine Pitrou). There are some security questions related to a CVE, but hopefully that can get resolved.
jcrist commentedon May 13, 2022
We no longer write
_metadatafiles by default, and in many cases no longer load file statistics. With that combined with the upstream pyarrow fix, I believe this can be closed.