Skip to content

Database Backend: Use configured serializer, instead of always pickling. - #2881

Closed
m4ddav3 wants to merge 9 commits into
celery:masterfrom
m4ddav3:master
Closed

m4ddav3 wants to merge 9 commits into
celery:masterfrom
m4ddav3:master

Conversation

@m4ddav3

@m4ddav3 m4ddav3 commented Oct 23, 2015

Copy link
Copy Markdown

Use the BLOB as an sa.BLOB
Serialise the result an add to the db as bytes

@codecov-io

Copy link
Copy Markdown

Current coverage is 90.56%

Merging #2881 into master will increase coverage by +0.64% as of cb93070

@@            master   #2881   diff @@
======================================
  Files          231     231       
  Stmts        31940   31967    +27
  Branches      2442    2456    +14
  Methods          0       0       
======================================
+ Hit          28721   28951   +230
- Partial        372     375     +3
+ Missed        2847    2641   -206

Review entire Coverage Diff as of cb93070


Uncovered Suggestions

  1. +0.07% via ...currency/asynpool.py#625...647
  2. +0.05% via ...currency/eventlet.py#49...63
  3. +0.05% via celery/bin/graph.py#169...183
  4. See 7 more...

Powered by Codecov. Updated on successful CI builds.

@ask

ask commented Oct 27, 2015

Copy link
Copy Markdown
Contributor

Is this backward compatible?

Comment thread celery/backends/database/models.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we then also remove PickleType, if it's no longer used?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I've removed the line

@m4ddav3

m4ddav3 commented Oct 29, 2015

Copy link
Copy Markdown
Author

I need to check this, but I believe it is backward compatible while the result encoding type is set to 'pickle'. If the user has result encoding set to 'json' for instance, then it will change the behaviour (I suddenly found readable data that I can access easily)
I guess a script to convert the column to the required encoding could be provided.

@ask ask changed the title Backend DB fixes Database Backend: Use configured serializer, instead of always pickling. Mar 12, 2016
@ask ask added this to the v4.0 milestone Mar 12, 2016
@ask

ask commented Mar 14, 2016

Copy link
Copy Markdown
Contributor

I was trying to merge this into master, and it does not pass tests, it seems to be missing some critical parts, like deserialization of the task/group payloads :(

@m4ddav3

m4ddav3 commented Apr 14, 2016

Copy link
Copy Markdown
Author

Ugh. I need to dig up a Vagrant/Docker celery + rabbitmq + db environment

@ask

ask commented Apr 14, 2016

Copy link
Copy Markdown
Contributor

@m4ddav3: cd funtests/stress/run; vagrant up; vagrant shell

@ask

ask commented Apr 14, 2016

Copy link
Copy Markdown
Contributor

No database in that environment though, but shouldn't be too difficult to add

@m4ddav3

m4ddav3 commented Apr 20, 2016

Copy link
Copy Markdown
Author

@ask ,
I've had a dig around, and added tests for json serialisation with an sqlite db backend.
The existing tests expect that the serializer be able to handle stored Python objects, which I think isn't necessarily the right thing to do.

Celery is written in Python, but the protocol can be implemented in any language

In order to keep in-line with the current methodology, but still be able to implement a JSON serializer, I suggest adding jsonpickle. This should enable enough compatibility to the current scheme of encoding/decoding exceptions and/or other serializable Python objects. What do you think?

@ask

ask commented Apr 22, 2016

Copy link
Copy Markdown
Contributor

jsonpickle would be nice, but sadly it has the same security concern as pickle, which is the ability to deserialize arbitrary objects by attribute path.

The tests must be rewritten to use json-safe data only, not sure how much work that is :(

@martincapello

Copy link
Copy Markdown

I created #5907, which is a rebased and slightly updated version of this PR.

@auvipy auvipy closed this Jan 6, 2020
@auvipy auvipy modified the milestones: 4.6, 4.4.x Jan 6, 2020
@auvipy auvipy removed this from the 4.4.x milestone Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants