title: Insert or update a document in ArangoDB fails with constraint violated
body: <p>I would like to achieve an Upsert in ArangoDB, but I can't get it working with the examples provided in the documentation of <a href="https://docs.arangodb.com/3.4/HTTP/Document/WorkingWithDocuments.html#create-document" rel="nofollow noreferrer">create-document</a>. My requests fail with a <code>unique constraint violated</code> error message.</p>
  
  <p>I'm inserting a document with a specific <code>_key</code> in a collection, and the <code>overwrite</code> option set to <code>true</code> as described in the documentation, but I still get the error messages. Here's the results of the described curl calls on my environment.</p>
  
  <p><strong>call #1:</strong></p>
  
  <pre><code>curl -X POST --header 'accept: application/json'\
               --data-binary @- --dump - \
               http://localhost:8529/_api/document/products\?overwrite\=true \
  &lt;&lt;EOF
  { "Hello": "Universe", "_key" : "lock" }
  EOF
  </code></pre>
  
  <p><strong>response #1:</strong></p>
  
  <pre><code>HTTP/1.1 202 Accepted
  X-Content-Type-Options: nosniff
  Location: /_db/_system/_api/document/products/lock
  Etag: "_X28xHz---_"
  Server: ArangoDB
  Connection: Keep-Alive
  Content-Type: application/json; charset=utf-8
  Content-Length: 58  
  
  {"_id":"products/lock","_key":"lock","_rev":"_X28xHz---_"}
  </code></pre>
  
  <p><strong>call #2:</strong> <em>(identique to the first one)</em></p>
  
  <pre><code>curl -X POST --header 'accept: application/json'\
               --data-binary @- --dump - \
               http://localhost:8529/_api/document/products\?overwrite\=true \
  &lt;&lt;EOF
  { "Hello": "Universe", "_key" : "lock" }
  EOF
  </code></pre>
  
  <p><strong>response #2:</strong></p>
  
  <pre><code>HTTP/1.1 409 Conflict
  X-Content-Type-Options: nosniff
  Server: ArangoDB
  Connection: Keep-Alive
  Content-Type: application/json; charset=utf-8
  Content-Length: 153
  
  {"error":true,"errorMessage":"unique constraint violated - in index 0 of type primary over [\"_key\"]; conflicting key: lock","code":409,"errorNum":1210}
  </code></pre>
  
  <p>I went through the documentation, I enabled and reviewed the server logs but I can't figure it out. Any help would be highly appreciated.</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>Just in case, if this can be of any help, I run ArangoDB server locally with Docker with the following docker-compose</p>
  
  <pre><code>version: '3'
  services:
    db:
      image: arangodb
      ports:
      - "8529:8529"
      environment:
        ARANGO_NO_AUTH: 1
      volumes:
        - ./arangodb3:/var/lib/arangodb3
      command: "--log.level startup=trace --log.level requests=trace --log.level info"
  </code></pre>
  
  <p>And here's the log from the server:</p>
  
  <pre><code>db_1  | 2018-12-09T08:56:16Z [1] DEBUG {requests} "http-request-begin","0x7f51ac946010","172.20.0.1","POST","HTTP/1.1","/_api/document/products?overwrite=true"
  db_1  | 2018-12-09T08:56:16Z [1] TRACE {requests} "http-request-body","0x7f51ac946010","{ \"Hello\": \"Universe\", \"_key\" : \"lock\" }\n"
  db_1  | 2018-12-09T08:56:16Z [1] TRACE {requests} "http-request-response","0x7f51ac946010","/_api/document/products?overwrite=true","HTTP\/1.1 409 Conflict\r\nX-Content-Type-Options: nosniff\r\nServer: ArangoDB\r\nConnection: Keep-Alive\r\nContent-Type: application\/json; charset=utf-8\r\nContent-Length: 153\r\n\r\n{\"error\":true,\"errorMessage\":\"unique constraint violated - in index 0 of type primary over [\\\"_key\\\"]; conflicting key: lock\",\"code\":409,\"errorNum\":1210}"
  db_1  | 2018-12-09T08:56:16Z [1] TRACE {requests} "http-request-statistics","0x7f51ac946010","172.20.0.1","POST","HTTP/1.1",409,41,153,"/_api/document/products?overwrite=true",read,0.000124931,queue,0.000000000,queue-size,0,request,0.000008106,total,0.017638445,error,false
  db_1  | 2018-12-09T08:56:16Z [1] INFO {requests} "http-request-end","0x7f51ac946010","172.20.0.1","POST","HTTP/1.1",409,41,153,"/_api/document/products?overwrite=true",0.017630
  </code></pre>