fsspec / fsspec/s3fs

S3FileSystem.checksum always returns cached value

Open
#293 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1k
Forks
305
Avg merge
22h 37m
Merged PRs (30d)
4

Description

Hi,

Encountered this unexpected behavior when using the checksum method to monitor changes in a file in a long-running app.

Description

S3FileSystem.checksum returns the same value for an object, even after the object has changed

Reproduce steps
  1. Create object s3://MY_BUCKET/MY_OBJECT on s3
  2. Run
import s3fs
fs=s3fs.S3FileSystem()
fs.checksum("s3://MY_BUCKET/foo")
  1. Overwrite the object with new contents (not using fs, but using e.g. the aws cli)
  2. In the same Python process as above, run fs.checksum("s3://MY_BUCKET/MY_OBJECT")

The results from 2 and 4 are identical, even though the file has changed.

Cause

It seems that checksum uses the default implementation of fsspec.AbstractFileSystem, which in turn creates the checksum from the output of fs.ls(detail=True). Since in the S3FileSystem implementation this gets passed a default argument refresh=False, the checksum is always computed on cached results.

Proposed solution

checksum should be implemented in S3FileSystem, in such a way that it always checks the actual state of the object, or at least provides the option to do so.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at S3FileSystem.checksum and compare it with fsspec.AbstractFileSystem's default checksum implementation, then trace fs.ls(detail=True) and its refresh=False default. Reproduce the external overwrite in one Python process; done means a later checksum can reflect the changed object, or an explicit refresh option is documented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, python
Domain
cloud
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.