Repository: pytorch
Issue: Torch DataLoader fails to reraise error from sqlalchemy.
Labels: module: dataloader,triaged

## 🐛 Bug

The `reraise` functionality in torch.utils.data.dataloader seems to break when used in combination with sqlalchemy. 

<!-- A clear and concise description of what the bug is. -->

## To Reproduce

I have a Dataset that uses an sqlalchemy engine to lookup item information. I'm still working out how to do that correctly, but in the process it seems like torch is not handling errors from sqlalchemy correctly: 

```
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 435, in __next__
    data = self._next_data()
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1065, in _next_data
    return self._process_data(data)
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/torch/utils/data/dataloader.py", line 1111, in _process_data
    data.reraise()
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/torch/_utils.py", line 429, in reraise
    raise self.exc_type(msg)
TypeError: __init__() missing 2 required positional arguments: 'params' and 'orig'
```

When I dug into this I printed the `msg` before this TypeError was raised and got

```
  File "/home/joncrall/code/kwcoco/kwcoco/coco_sql_dataset.py", line 361, in _yield_per
    chunk = result.fetchall()
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 1288, in fetchall
    self.connection._handle_dbapi_exception(
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/sqlalchemy/engine/base.py", line 1510, in _handle_dbapi_exception
    util.raise_(
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 1284, in fetchall
    l = self.process_rows(self._fetchall_impl())
  File "/home/joncrall/.local/conda/envs/py38/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 1230, in _fetchall_impl
    return self.cursor.fetchall()
sqlalchemy.exc.DatabaseError: (sqlite3.DatabaseError) database disk image is malformed
```

So I'm doing something wrong where my sqlite database is malformed (likely writing to it over multiple workers). But the issue with torch is that it is not reraising the error correctly. This seems related to: https://github.com/celery/celery/issues/5057

## Expected behavior

I would expect the error hit by sqlalchemy to be raised. 

## Environment

Please copy and paste the output from our
[environment collection script](https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py)
(or fill out the checklist below manually).

You can get the script and run it with:
```
wget https://raw.githubusercontent.com/pytorch/pytorch/master/torch/utils/collect_env.py
# For security purposes, please check the contents of collect_env.py before running it.
python collect_env.py
```

```
(py38) joncrall@Ooo:~/code/netharn/dev$ python collect_env.py
Collecting environment information...
PyTorch version: 1.7.1
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.2 LTS (x86_64)
GCC version: (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Clang version: 10.0.0-4ubuntu1 
CMake version: version 3.17.3

Python version: 3.8 (64-bit runtime)
Is CUDA available: True
CUDA runtime version: 10.1.243
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 450.102.04
cuDNN version: /home/joncrall/.local/cuda-10.1/targets/x86_64-linux/lib/libcudnn.so.7.6.5
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] adabelief-pytorch==0.0.5
[pip3] numpy==1.19.5
[pip3] pytorch-ranger==0.1.1
[pip3] torch==1.7.1
[pip3] torch-cluster==1.5.7
[pip3] torch-geometric==1.6.1
[pip3] torch-liberator==0.0.5
[pip3] torch-optimizer==0.0.1a16
[pip3] torch-scatter==2.0.5
[pip3] torch-sparse==0.6.7
[pip3] torchvision==0.8.2
[conda] adabelief-pytorch         0.0.5                    pypi_0    pypi
[conda] blas                      1.0                         mkl  
[conda] mkl                       2020.2                      256  
[conda] mkl-service               2.3.0            py38he904b0f_0  
[conda] mkl_fft                   1.1.0            py38h23d657b_0  
[conda] mkl_random                1.1.1            py38h0573a6f_0  
[conda] numpy                     1.19.0                   pypi_0    pypi
[conda] pytorch-ranger            0.1.1                    pypi_0    pypi
[conda] torch                     1.7.1                    pypi_0    pypi
[conda] torch-cluster             1.5.7                    pypi_0    pypi
[conda] torch-geometric           1.6.1                    pypi_0    pypi
[conda] torch-liberator           0.0.5                     dev_0    <develop>
[conda] torch-optimizer           0.0.1a16                 pypi_0    pypi
[conda] torch-scatter             2.0.5                    pypi_0    pypi
[conda] torch-sparse              0.6.7                    pypi_0    pypi
[conda] torchvision               0.8.2                    pypi_0    pypi
```


cc @SsnL @VitalyFedyunin @ejguan