janl opened a new issue #3750:
URL: https://github.com/apache/couchdb/issues/3750


   Given a database that is populated two documents and a ddoc:
   
   ```
   #!/bin/sh
   curl -su admin:admin 'http://localhost:15984/debug' -X DELETE
   sleep 1
   curl -su admin:admin 'http://localhost:15984/debug?q=2' -X PUT
   sleep 1
   curl -su admin:admin 'http://localhost:15984/debug/_design/test' -X PUT 
--data-binary '{ "views": { "test": { "map": "function (doc) { emit(doc.foo, 
\"fooValue\") ; emit(doc.foo) ; emit(doc.bar) ; emit(doc.bar, \"crayon!\") ; 
emit(doc.bar, \"multiple values!\") ; emit(doc.bar, \"crayon!\") }" } } }'
   curl -su admin:admin 'http://localhost:15984/debug/doc1' -X PUT 
--data-binary '{ "foo": "foo", "bar": "bar" }'
   curl -su admin:admin 'http://localhost:15984/debug/doc2' -X PUT 
--data-binary '{ "foo": "foo", "bar": "bar" }'
   ```
   
   Querying this view repeatedly returns one of two results.
   
   ```
   while (true); do
      curl -su admin:admin 
'http://localhost:15984/debug/_design/test/_view/test?startkey="foo"&skip=3&limit=0'
      sleep 1
   done
   ```
   
   Meta missing:
   
   ```
   {"rows":[]}
   ```
   
   Meta present:
   
   ```
   {"total_rows":12,"offset":11,"rows":[
   
   ]}
   ```
   
   I’ve tracked this down from `fabric_view_map:go()`: 
   - it successfully creates two workers, one for each shard:
   
   ```
    Workers0: 
[{shard,<<"shards/00000000-7fffffff/debug.1631717845">>,'[email protected]',<<"debug">>,[0,2147483647],#Ref<0.1831788800.3241148417.184777>,[{props,[]}]},{shard,<<"shards/80000000-ffffffff/debug.1631717845">>,'[email protected]',<<"debug">>,[2147483648,4294967295],#Ref<0.1831788800.3241148417.184778>,[{props,[]}]}]
   ```
   
   Those workers successfully call the view handling callback with the correct 
meta info:
   
   ```
    sending Db: <<"shards/80000000-ffffffff/debug.1631717845">>, Meta back to 
Callback: {meta,[{total,6},{offset,4}]}
    sending Db: <<"shards/00000000-7fffffff/debug.1631717845">>, Meta back to 
Callback: {meta,[{total,6},{offset,4}]}
   ```
   
   (each doc lives on one of the shards, so the numbers for each shard there 
are the same)
   
   However!
   
   In the case where the meta data is missing, the 
`fabric_view_map:handle_message({meta, Meta0})` is only called once:
   
   ```
   Incoming Meta0: [{total,6},{offset,4}]
   Current State Total0: 0
   Current State Offset0: 0
   
   Sum(State, Incoming)  Total: 6
   Sum(State, Incoming) Offset: 4
   any counters true % from `case fabric_dict:any(0, Counters1) of`
   
   ```
   
   Whereas when the meta data is there, we see this invoked twice:
   
   ```
   Incoming Meta0: [{total,6},{offset,4}]
   Current State Total0: 0
   Current State Offset0: 0
   
   Sum(State, Incoming) Total: 6
   Sum(State, Incoming) Offset: 4
   any counters true % from `case fabric_dict:any(0, Counters1) of`
   
   Incoming Meta0: [{total,6},{offset,4}]
   Current State Total0: 6
   Current State Offset0: 4
   Sum(State, Incoming) Total: 12
   Sum(State, Incoming) Offset: 8
   any counters false % from `case fabric_dict:any(0, Counters1) of`
   ```
   
   After here it calls
   
   ```
           {Go, Acc} = Callback({meta, Meta}, AccIn),
   ```
   
   which looks like it places the meta into the result set. This isn’t called 
in the previous case.
   
   I’m not super firm with the `fabric_rpc` mechanisms, but it looks like we 
are losing `map_doc` response messages somewhere and I’d appreciate a second 
look.


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