Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Work around the special case of rails and generate * Alternate approach to generate issue
- Loading branch information
Showing
4 changed files
with
16 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a298dd0
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.
3.11.4/5 is an issue for me. I assume due to this commit. I'm not able to replicate the issue in a simple repo yet but in my project I am using Sidekiq to perform a job from a Rails controller and it is sending a hash to Sidekiq (Using Sidekiq inline testing, so jobs are not going through the Sidekiq server). In 3.11.3 I get a hash in the Sidekiq job but with 3.11.4 I get an error saying it is a string.
a298dd0
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.
The only significant change is is mimic_json.c line 387 so I suspect it has something to do with the active support work around which means the state objects are most likely different in some way. To debug we will need to look at the object when it works vs when it doesn't. Do you know enough about C to be able to put in that kind of debug information? If note is there a was to set up a test case? Or an image I can work with?
a298dd0
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.
I ran into an issue like this - in our case for two jobs, in error we were calling Sidekiq's
perform_async
with objects as the argument.Previously, these objects were automatically converted to a hash or json in the process of sending the job to the background queue and after updating from 3.11.3 to 3.11.5, the object itself was being stored as a string.
a298dd0
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.
Do you see different behaviour when comparing the json gem and oj in that situation?
Any chance of a stack trace to see what is being called?
a298dd0
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.
While there was definitively some change in behaviour here I had a closer look at the code that was the root of my problem. Turns out I was passing some objects (ActionController::Parameters) instead of a hash to Sidekiq. I modified this to correct usage, converting it to a hash, and I am no longer experiencing this issue.
I only ran my tests for this to occur so not sure if this was an issue when running a normal server. For testing Sidekiq will run jobs differently than with a server. It will execute the jobs immediately (inline testing). I see that it will generate JSON for the input data.
a298dd0
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.
Great, so problem solved, right?
a298dd0
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.
Hi @ohler55, thanks for your amazing work on Oj! I found an "issue" in the way
BigDecimal
is handled when upgrading from v3.11.3 to v3.11.4 when usingJSON.generate
.It's a rails project with using those configs:
When using v3.11.3:
BigDecimal
values are converted to numerical values.When using v3.11.4:
In this case,
BigDecimal
values are being converted to string values whenJSON.generate
is used. Is this the correct behaviour or is this a bug?I found this when some ActiveJobs (with Sidekiq as the queue adapter) started to fail, those jobs receive
BigDecimal
values and now those values are being processed asstring
when the job deserializes the arguments. As far as I could debug it seems like Sidekiq usesJSON.generate
when pushing the job data to the Redis database, thus creating inconsistency.a298dd0
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.
The traces help, thanks. I'll look into it and see what changed. @Watson1978 was kind enough to spend some time optimizing dumping so maybe something in the changes caused the issue. I think this is a different issue though. Would you mind creating a separate issue for this?
a298dd0
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.
We're running into a similar issue with timestamps:
3.11.3:
3.11.4:
running with
Oj.optimize_rails
a298dd0
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.
Please create a separate issue for this. The original had nothing to do with time string formats.
a298dd0
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.
@grk when you create the new issue please let me know what results you get without Oj and just using the JSON gem with rails. I get the 3.11.4 output without Oj and just using the JSON gem.