Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disk I/O error #15

Closed
4sachi opened this issue Oct 25, 2021 · 11 comments
Closed

disk I/O error #15

4sachi opened this issue Oct 25, 2021 · 11 comments

Comments

@4sachi
Copy link

4sachi commented Oct 25, 2021

Hi

I have tried to query the SQLite file present in the S3 bucket using sqlite-s3-query package but I'm getting "Exception: disk I/O error".
The object is private and it is present in a private bucket. I have provided the correct access and secret keys of the user also verified that the user is able to access the object using boto3

Please find the complete details below,

version of sqlite_s3_query - sqlite-s3-query 0.0.44
the file format used in s3 bucket - filename.db, filename.sqlite
region, access key id, and secret access key are stored in environment variables

sample code

from sqlite_s3_query import sqlite_s3_query s3_url="https://<bucket>.s3.<region>.amazonaws.com/<key>" with sqlite_s3_query(url=s3_url) as query: with query('SELECT * FROM table1 WHERE name= ?', params=('name1',)) as (columns, rows): for row in rows: print(row)

Error message
Error observedTraceback (most recent call last):
File "C:\Users\user1\Downloads\db.py", line 29, in
with sqlite_s3_query(url='') as query:
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 117, in enter
return next(self.gen)
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlite_s3_query.py", line 319, in sqlite_s3_query
with
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\contextlib.py", line 117, in enter
return next(self.gen)
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlite_s3_query.py", line 275, in get_db
run(libsqlite3.sqlite3_open_v2, f'file:/{file_name}'.encode() + b'\0', byref(db), SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, vfs_name.encode() + b'\0')
File "C:\Users\user1\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlite_s3_query.py", line 73, in run
raise Exception(libsqlite3.sqlite3_errstr(res).decode())
Exception: disk I/O error

Could you please help me with this

Thanks,
4sachi

@michalc
Copy link
Owner

michalc commented Oct 27, 2021

Hello 👋

I can try to have a look, but I think I’m going to need a complete example so I can run the exact same code.

Also, do you have very specific details of the system this is running on? It looks like Windows from the paths (and I have very little experience of Windows, and I think no experience of running Python on Windows)

Michal

@michalc
Copy link
Owner

michalc commented Nov 28, 2021

Let me know if you have any more details? (Otherwise will close the issue)

@michalc
Copy link
Owner

michalc commented Dec 12, 2021

Closing, but feel free to reopen

@michalc michalc closed this as completed Dec 12, 2021
@ionox0
Copy link

ionox0 commented Jan 31, 2023

Just FYI I am also seeing this error. I believe it occurs on 2nd attempt of downloading, after 1st attempt of downloading is cancelled. Perhaps clearing the cache would fix it

@michalc
Copy link
Owner

michalc commented Jan 31, 2023

@ionox0 can you provide more details, such as a reproducible example? Specifically: which cache are you referring to?

@cjusko
Copy link

cjusko commented Mar 11, 2024

Hi! I'm seeing this error as well. The sqlite file that I'm attempting to access is fairly sizeable, about 3GB. However, I did have this working with the same sqlite file just a few weeks ago. My exact setup is as follows:

with sqlite_s3_query(url=s3_url, get_credentials=lambda now: ( region,access_key,secret_key,token )) as query:
        table_query = """SELECT name FROM sqlite_master WHERE type='table';"""
        with query(table_query) as (columns, rows):
            for row in rows:
                print(row)

which results in the same Exception: disk I/O error error.

@cjusko
Copy link

cjusko commented Mar 11, 2024

Trying to run the same table name query on a smaller, test sqlite file still results in the disk I/O error. I'm running with Python 3.10, but got the same error on Python 3.8. Versioning is enabled on the bucket.

sqlite-s3-query v0.0.78

@michalc
Copy link
Owner

michalc commented Mar 11, 2024

Hi @cjusko,

Are you able to share the specific SQLite file? Also - what version of SQLite?

Thanks,

Michal

@cjusko
Copy link

cjusko commented Mar 15, 2024

@michalc

Thanks for getting back! Sorry about the delay. I was able to figure this out after spending some time messing with the permissions on the bucket.

For future reference, I was receiving this error because of an update our IT dept conducted which inadvertently removed s3:GetObject and s3:GetObjectVersion permissions. Adding those back resolved all issues we were having. So if this issue comes back up for anyone in the future, that's the first place I'd check.

Thanks again!

@michalc
Copy link
Owner

michalc commented Mar 15, 2024

@cjusko

Ah good to know - thanks! So it probably would have caused a 403 response, which then we would convert to a exception, but then this gets converted to what I think would surface as a disk i/o error at

return SQLITE_IOERR

Maybe this should be better surfaced somehow...

@michalc
Copy link
Owner

michalc commented Mar 15, 2024

@cjusko (and others that get here)

As of v0.0.80 sqlite-s3-query will now raise a range of more specific exceptions, including more consistently surfacing httpx exceptions, which are raised in the case of (for example) 403s from S3 in the case of not having the right permissions.

There are some details in the Exceptions section of the README

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants