Kinto/kinto

Dev server returns 409 on POST

Closed this issue · 1 comments

Steps to reproduce

➜  http POST $SERVER/buckets/main/collections -a mat:123     
HTTP/1.1 201 Created
Access-Control-Expose-Headers: Content-Type, Content-Length, Backoff, Retry-After, Alert
Connection: keep-alive
Content-Length: 96
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Tue, 18 Aug 2020 09:53:05 GMT
ETag: "1597744385553"
Last-Modified: Tue, 18 Aug 2020 09:53:05 GMT
Server: nginx
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "KuX3wy-C",
        "last_modified": 1597744385553
    },
    "permissions": {
        "write": [
            "account:mat"
        ]
    }
}

➜  http POST $SERVER/buckets/main/collections -a mat:123
HTTP/1.1 201 Created
Access-Control-Expose-Headers: Content-Type, Content-Length, Backoff, Retry-After, Alert
Connection: keep-alive
Content-Length: 96
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Tue, 18 Aug 2020 09:53:08 GMT
ETag: "1597744388379"
Last-Modified: Tue, 18 Aug 2020 09:53:08 GMT
Server: nginx
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "k4MaRMTU",
        "last_modified": 1597744388379
    },
    "permissions": {
        "write": [
            "account:mat"
        ]
    }
}

➜  http POST $SERVER/buckets/main/collections/k4MaRMTU/records -a mat:123
HTTP/1.1 201 Created
Access-Control-Expose-Headers: Content-Type, Content-Length, Backoff, Retry-After, Alert
Connection: keep-alive
Content-Length: 124
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Tue, 18 Aug 2020 09:53:22 GMT
ETag: "1597744402010"
Last-Modified: Tue, 18 Aug 2020 09:53:22 GMT
Server: nginx
X-Content-Type-Options: nosniff

{
    "data": {
        "id": "4a11b2f9-8c12-4348-ab6c-41da4da4ef5c",
        "last_modified": 1597744402010
    },
    "permissions": {
        "write": [
            "account:mat"
        ]
    }
}

➜  http POST $SERVER/buckets/main/collections/k4MaRMTU/records -a mat:123
HTTP/1.1 409 Conflict
Access-Control-Expose-Headers: Content-Type, Content-Length, Backoff, Retry-After, Alert
Connection: keep-alive
Content-Length: 100
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'; base-uri 'none';
Content-Type: application/json
Date: Tue, 18 Aug 2020 09:53:24 GMT
Retry-After: 3
Server: nginx
X-Content-Type-Options: nosniff

{
    "code": 409,
    "errno": 122,
    "error": "Conflict",
    "message": "Integrity constraint violated, please retry."
}

See also #2295

It was caused by kinto-changes plugin. To fix the issue, I had to prevent history events to be created in /buckets/monitor

kinto.history.exclude_resources = /buckets/monitor

Something is causing the duplication of a history entry there, and I don't have a reasonable explanation for now. I opened Kinto/kinto-changes#199