No way to indicate that a query failed if it is completed off-thread

Bug #1261597 reported by James Henstridge
6
This bug affects 1 person
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::finished() method provides an argument that would let us report a failure, but this is not exposed via Reply::finished() (or any other Reply method).

Related branches

Revision history for this message
Michi Henning (michihenning) wrote :

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?

Changed in unity-scopes-api:
status: New → Fix Committed
Michal Hruby (mhr3)
Changed in unity-scopes-api:
status: Fix Committed → In Progress
assignee: nobody → Michi Henning (michihenning)
importance: Undecided → Medium
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:unity-scopes-api at revision 118, scheduled for release in unity-scopes-api, milestone Unknown

Changed in unity-scopes-api:
status: In Progress → Fix Committed
Michal Hruby (mhr3)
Changed in unity-scopes-api:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.