alvarolivie opened a new pull request, #6177:
URL: https://github.com/apache/couchdb/pull/6177

   ## Overview
   
   The main issue was the error `missing_stub` being treated as a generic error 
and not counting towards the quorum. This meant that one document with this 
error returned an error for everything but the changes may have had gone 
through.
   
   ## Testing recommendations
   
   I've implemented a few tests that cover the main use case but I recommend 
the script provided by @nickva to recreate the issue. I also used it to test my 
solution. I'll leave a copy below:
   
   ```
   #!/bin/sh
   
   # Missing stub bug.
   #
   # Whole update fails with 412 if we send {"stub": true} when one shard copy 
is
   # live but hasn't commited the previous revision yet. It throws missing which
   # blow up the coordinator regardless of whatever other reponses are (so we're
   # not doing the quorum thing).
   
   # 1. Use a dev cluster with 3 nodes
   # 2. Make node3 slow:
   #
   #   - On top of the handle_info({update_docs, ...}, Db) clause in 
couch_db_updater.erl:
   #
   #     case
   #         node() =:= '[email protected]' andalso not ReplicatedChanges andalso
   #             mem3:dbname(Db#db.name) =:= ~"db"
   #     of
   #         true -> timer:sleep(10000);
   #         false -> ok
   #     end,
   #
   # 3. Set `serialize_worker_startup = false` in rel/overlay/etc/default.ini
   #
   # 4. ./dev/run -n 3 -a adm:pass and run this script
   
   set -eu
   
   h() {
       http --ignore-stdin --print=b --pretty=none "$@"
   }
   
   DB=http://adm:[email protected]:15984
   DB3=http://adm:[email protected]:35984
   h delete $DB/db > /dev/null
   h put $DB/db q==8 n==3
   
   # create though n1, update through slower n3
   INLINE='{"a.txt":{"content_type":"text/plain","data":"cG90YXRv"}}'
   STUBBY='{"a.txt":{"content_type":"text/plain","revpos":1,"stub":true}}'
   
   echo "==== stubby ===="
   for i in $(seq 5); do
       REV=$(h put $DB/db/doc$i _attachments:="$INLINE" | jq -r .rev)
       h put $DB3/db/doc$i _rev=$REV a:=42 _attachments:="$STUBBY"
   done
   
   echo "===== get revs (2-... after error means other copies got the writen)"
   for i in $(seq 5); do
       h get $DB/db/doc$i | jq -r '"\(._id) \(._rev)"'
   done
   ```
   
   ## Related Issues or Pull Requests
   
   This PR solves https://github.com/apache/couchdb/issues/6175.
   
   ## Checklist
   
   - [ ] This is my own work, I did not use AI, LLM's or similar technology
   - [ ] Code is written and works correctly
   - [ ] Changes are covered by tests
   - [ ] Any new configurable parameters are documented in 
`rel/overlay/etc/default.ini`
   - [ ] Documentation changes were made in the `src/docs` folder
   - [ ] Documentation changes were backported (separated PR) to affected 
branches
   


-- 
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]

Reply via email to