-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1.x: Change the workers to capture the stack trace #3937
Conversation
No. At least make it conditional to a system parameter / global boolean variable. |
👍 as is. The cost is very low and the benefit is very high. |
@akarnokd added a system property to make if off by default. |
I would like this to be default behavior. Learning Rx is hard and we are making it harder by default. Let users opt into over-optimizations. |
*/ | ||
public class SchedulerContextException extends Exception { | ||
public static Throwable create() { | ||
if (System.getProperty("rxjava.captureSchedulerContext", "false").equals("true")) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better. Do you want this to be changeable at runtime?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. When things go wrong it can be helpful to be able to enable more logging without having to restart the VM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, in that case, I'd consider a public static AtomicBoolean instead of the hash-lookup and string comparison. From security perspective, if you can set System properties, you could just as set an AtomicBoolean, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably just a static volatile boolean, right? Atomicity isn't needed
since it's only read by RxJava and only written by application code.
On Fri, May 13, 2016, 11:58 AM David Karnok notifications@github.com
wrote:
In src/main/java/rx/internal/schedulers/SchedulerContextException.java
#3937 (comment):
- * http://www.apache.org/licenses/LICENSE-2.0
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- /
+package rx.internal.schedulers;
+
+/*- * Used only for providing context around where work was scheduled should an error occur in a different thread.
- */
+public class SchedulerContextException extends Exception {- public static Throwable create() {
if (System.getProperty("rxjava.captureSchedulerContext", "false").equals("true")) {
Okay, in that case, I'd consider a public static AtomicBoolean instead of
the hash-lookup and string comparison. From security perspective, if you
can set System properties, you could just as set an AtomicBoolean, right?—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/ReactiveX/RxJava/pull/3937/files/9630081dc8ef75edad8dc397a661cf61d4ee57fd#r63234396
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything else @JakeWharton @akarnokd?
359ef10
to
e277814
Compare
You have a lot of test failures. |
* Immediately change the behavior to of the {@link SchedulerContextException#create()} method. | ||
* @param captureSchedulerContext | ||
*/ | ||
public static void setCaptureSchedulerContext(boolean captureSchedulerContext) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be public API for applications to use? Because it's currently in an internal package.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wasn't an API until it was changed to volatile boolean
and was just always reading from System.getProperty()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems unnecessary to me. System#getProperty
checks the security manager. If the security manager throws an exception then the boolean is set to false (making it impossible to set to true).
I would rather we just read from a property always. Why wouldn't we do this?
RXJava is hard to debug - lots of people agree on this. I know of large non-trivial projects that avoided using RXJava because it hard to debug. Non-trivial projects do I/O, and serialization - those are the performance problems, not micro-optimizations. Users will care more about it being easier to debug than being micro-optimized. This should be default to make it less hard. |
I've changed it back to always getting the value from the system properties because makes a fine public API and it makes the tests work again. I've added some code to mitigate the overhead of doing the check multiple times. |
Still failing... |
Found it the test worked if run in isolation but failed if they were run en masse because of caching. Added pooled work resets in two places seems to fix the issue. |
}); | ||
|
||
try { | ||
getScheduler().createWorker().schedule(new Action0() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This leaks the worker.
…duled actions to increase the readability of uncaught and fatal exceptions that bubble up to the schedulers.
I want to increase debug support in RxJava, but I'd think, based on the feedback on #3965, that such capture is not enough. I suggest closing this PR, unless you can spend some time with it before 1.1.7. Also I'd like your feedback on #4007. It's tracking grabs the stacktrace for A more elaborate solution would be that in case of a crash, the operator graph could be walked and dumped in a consumable format. Unfortunately, to support this, the |
I'm closing this for now due to test failures and merge conflicts. In addition, I suggest extending #4007, once merged, by adding If you have further input on the issue, don't hesitate to reopen this issue or post a new one. |
Watched @dlew presentation of the pit falls of debugging RxJava https://www.youtube.com/watch?v=QdmkXL7XikQ&feature=youtu.be&t=38m12s
This change is to create an exception when a thread based
Scheduler.Worker
is constructed and reused it for all subsequent scheduled actions to increase the readability of uncaught and fatal exceptions that bubble up to the schedulers but spread the cost out across many scheduled actions.A future improvement to spread the cost out even more, that I didn't want to do in the first attempt, would to create the exception when
Scheduler.io()
is called and reuse the exception across multipleWorker
s.The example from the presentation
Used to print this just this exception with no mention the Main class.
But will now print the exception above but with an additional caused by