No way to indicate that a query failed if it is completed off-thread
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
unity-scopes-api |
Fix Released
|
Medium
|
Michi Henning |
Bug Description
When a scope's QueryBase::run() method is called to execute a query, it has two choices:
1. Execute the query on-thread, so that the query completes when the method returns.
2. Hold a reference to the reply object and return immediately. The query can then be driven from a different thread, and only completes when reply->finished() is called or the reply object is destroyed.
In the first case, errors can be reported by throwing an exception.
In the off-thread case, we can't rely on exceptions because we are on a different stack. The ReplyImpl:
Related branches
- Michal Hruby (community): Approve
- PS Jenkins bot (community): Approve (continuous-integration)
-
Diff: 574 lines (+130/-45)21 files modifiedCMakeLists.txt (+1/-1)
debian/changelog (+8/-0)
demo/client.cpp (+20/-6)
demo/scopes/scope-B/scope-B.cpp (+7/-2)
include/scopes/ReceiverBase.h (+5/-3)
include/scopes/Reply.h (+16/-5)
include/scopes/internal/MWReply.h (+1/-1)
include/scopes/internal/ReplyImpl.h (+1/-0)
include/scopes/internal/ReplyObject.h (+1/-1)
include/scopes/internal/zmq_middleware/ZmqReply.h (+1/-1)
src/Reply.cpp (+4/-0)
src/internal/QueryCtrlImpl.cpp (+4/-2)
src/internal/QueryObject.cpp (+3/-3)
src/internal/ReplyImpl.cpp (+36/-3)
src/internal/ReplyObject.cpp (+11/-11)
src/internal/ScopeImpl.cpp (+1/-1)
src/internal/ScopeObject.cpp (+2/-2)
src/internal/zmq_middleware/ReplyI.cpp (+3/-1)
src/internal/zmq_middleware/ZmqReply.cpp (+2/-1)
src/internal/zmq_middleware/capnproto/Reply.capnp (+1/-0)
test/gtest/scopes/Runtime/Runtime_test.cpp (+2/-1)
Changed in unity-scopes-api: | |
status: | New → Fix Committed |
Changed in unity-scopes-api: | |
status: | Fix Committed → In Progress |
assignee: | nobody → Michi Henning (michihenning) |
importance: | Undecided → Medium |
Changed in unity-scopes-api: | |
status: | Fix Committed → Fix Released |
run() is a oneway method internally. create_query() invokes run() on the server side asynchronously, to avoid blocking if run() is implemented synchronously. If run() throws, the client receives a finished() callback with the error indicator set (but no details about the exception).
We could add a set_exception( std::exception_ ptr) method to Reply, so the scope can push an error. Calling this would implicitly send the finished message with the error flag back to the client.
I'm not sure whether we should try to move the error over the wire though. As far as I know, the SSS protocol doesn't allow errors to be returned from scopes as part of the results, so moving the exception over the wire would break location transparency.
But set_exception() could log the error, so it's possible to find out when things go wrong with a scope. Would that work for you?