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

claim_bucket not idempotent #2

Open
rufuspollock opened this issue Aug 13, 2011 · 0 comments
Open

claim_bucket not idempotent #2

rufuspollock opened this issue Aug 13, 2011 · 0 comments

Comments

@rufuspollock
Copy link
Member

Reported by wwaites.

The claim_bucket method takes an optional argument. If this argument does not already exist as a key, a UUID is created. However the uuid is created randomly. This means that starting with the same source data, populating two separate filesystems will result in different keys. This is the behaviour with the pairtree store, and is different from the S3 store, for example.

This is particularly a problem with ORDF and creating a back-end storage module that uses OFS. When ORDF saves a graph, the graph has an identifier which is a URI. This is the natural key to use. The current pairtree back-end takes this URI and if it is not already in the urn:uuid namespace, transforms it into that space in a stable way, using uuid3(NAMESPACE_URL, "http://..."). The resulting UUID is then used as a stable key. This means that storing the same graph again, even in a fresh filesystem, will result in the same identifier being used.

Suggested fix:

    if key is URI:
        if not key.startswith("urn:uuid:"):
            new_key = uuid3(NAMESPACE_URL, key)
            # save original uri so it can be later recovered
            metadata["canonical_uri"] = key
            key = new_key
        # strip urn:uuid if it is required by the back-end
        key = key[9:]
    else:
        current behaviour

The key generation should probably be factored out of the back-ends so that it behaves the same way across all of them.

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

1 participant