jan-aleksi opened a new issue, #6126: URL: https://github.com/apache/couchdb/issues/6126
### Version 3.5.2 ### Describe the problem you're encountering When a document with an attachment is deleted and then recreated with the same id and attachment name but different contents, the updated attachment data is not replicated correctly if the deletion is not replicated separately first. This happens with both transient and continuous replication if continuous replication fails for some reason (like temporary connection issue) before the new document is inserted. ### Expected Behaviour I would expect attachment data to be updated in the replication target similarly to how it's updated in the source. I would probably also expect that when recreating a document with an attachment, the `revpos` field in `_attachments` would match the revision number, but this isn't really something I care about as a user. ### Steps to Reproduce These steps require `docker` and `jq` and use transient replication for convenience. I've Start two couchdb docker containers on the same docker network: ```sh docker network create couchdb-test docker run --name couch1 -d -p 5984:5984 --network couchdb-test -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin couchdb docker run --name couch2 -d -p 5985:5984 --network couchdb-test -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=admin couchdb ``` Create `test` database in `couch1` with a single document with an attachment: ```sh curl -u admin:admin -X PUT 'http://localhost:5984/test' curl -u admin:admin -X PUT 'http://localhost:5984/test/testdoc' \ -H 'Content-Type: application/json' \ -d '{"_id":"testdoc","_attachments":{"file":{"content_type":"text/plain","data":"YWFhYWEK"}}}' ``` Replicate `test` from `couch1` to `couch2` and check the data: ```sh curl -u admin:admin -X POST 'http://localhost:5984/_replicate' \ -H 'Content-Type: application/json' \ -d '{"source":"http://admin:admin@couch1:5984/test","target":"http://admin:admin@couch2:5984/test","create_target":true,"continuous":false}' curl -s -u admin:admin "http://localhost:5984/test/testdoc" | jq # { # "_id": "testdoc", # "_rev": "1-186e7841f8df12ab5cf28dad9d2033b8", # "_attachments": { # "file": { # "content_type": "text/plain", # "revpos": 1, # "digest": "md5-oQV6i1d2MQFpml+YQVk7QA==", # "length": 5, # "stub": true # } # } # } curl -s -u admin:admin "http://localhost:5985/test/testdoc" | jq # { # "_id": "testdoc", # "_rev": "1-186e7841f8df12ab5cf28dad9d2033b8", # "_attachments": { # "file": { # "content_type": "text/plain", # "revpos": 1, # "digest": "md5-oQV6i1d2MQFpml+YQVk7QA==", # "length": 5, # "stub": true # } # } # } ``` Delete the document in `couch1` and recreate it with different attachment contents: ```sh curl -u admin:admin -X DELETE \ "http://localhost:5984/test/testdoc?rev=$(curl -s -u admin:admin "http://localhost:5984/test/testdoc" | jq '._rev')" curl -u admin:admin -X PUT 'http://localhost:5984/test/testdoc' \ -H 'Content-Type: application/json' \ -d '{"_id":"testdoc","_attachments":{"file":{"content_type":"text/plain","data":"YmJiYmIK"}}}' ``` Replicate `test` from `couch1` to `couch2` and check the data: ```sh # Replicate "test" database from couch1 to couch2 curl -u admin:admin -X POST 'http://localhost:5984/_replicate' \ -H 'Content-Type: application/json' \ -d '{"source":"http://admin:admin@couch1:5984/test","target":"http://admin:admin@couch2:5984/test","create_target":true,"continuous":false}' curl -s -u admin:admin "http://localhost:5984/test/testdoc" | jq # { # "_id": "testdoc", # "_rev": "3-95d08e7c58dd79d6617d19f49bf836e0", # "_attachments": { # "file": { # "content_type": "text/plain", # "revpos": 1, # "digest": "md5-imQ12rhoOgQEok8WoOwkyg==", # "length": 6, # "stub": true # } # } # } curl -s -u admin:admin "http://localhost:5985/test/testdoc" | jq # { # "_id": "testdoc", # "_rev": "3-95d08e7c58dd79d6617d19f49bf836e0", # "_attachments": { # "file": { # "content_type": "text/plain", # "revpos": 1, # "digest": "md5-oQV6i1d2MQFpml+YQVk7QA==", # "length": 5, # "stub": true # } # } # } ``` Document revisions match, but attachment data differs! Clean up the docker containers and networks: ``` docker rm $(docker stop couch1 couch2) docker network rm couchdb-test ### Your Environment We are running couchdb in docker in a single node setup with database instances replicating data between each other in ad hoc "clusters". ### Additional Context I'm happy to provide more context if needed. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
