Skip to content
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

[FIX] web/database manager: fix MemoryError when restoring big databases #12376

Closed
wants to merge 1 commit into from

Conversation

olilau
Copy link
Contributor

@olilau olilau commented Jun 10, 2016

Description of the issue/feature this PR addresses:
When using the database manager to restore a very big zip with filestore
archive, a MemoryError can be raised by Python in the 'binascii' module
when Odoo web client is trying to convert the uploaded file to base6

Current behavior before PR:
Database restoration fails.

Desired behavior after PR is merged:
Database restoration succeeds.

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

When using the database manager to restore a very big zip with filestore
archive, a MemoryError can be raised by Python in the 'binascii' module
when Odoo web client is trying to convert the uploaded file to base64.

This fix creates the base64 encoded data in chunks to avoid this issue.

The same fix is also used in the 'db' service when it received the base
64 encoded data and tries to convert it back to a file.

Closes issue 680195

When using the database manager to restore a very big zip with filestore
archive, a MemoryError can be raised by Python in the 'binascii' module
when Odoo web client is trying to convert the uploaded file to base64.

This fix creates the base64 encoded data in chunks to avoid this issue.

The same fix is also used in the 'db' service when it received the base
64 encoded data and tries to convert it back to a file.

Closes issue 680195
@xmo-odoo
Copy link
Collaborator

Maybe using base64 streamreader/streamwriter could work with less additional complexity? E.g.

out = cStringIO()
shutil.copyfileobj(backup_file, codecs.getwriter('base64')(out))
data = out.getvalue()

and

reader = codecs.getreader('base64')(cStringIO(data))
shutil.copyfileobj(reader, data_file)

?

@antonylesuisse
Copy link
Contributor

Data will still be O(dbsize) the solution would be to use an other api than

         request.session.proxy("db").restore(master_pwd, name, data, copy)

One that accept a fileobject.

@C3POdoo C3POdoo added the RD research & development, internal work label Jun 13, 2016
@CGenie
Copy link

CGenie commented Dec 13, 2017

Please take a look at #21614

@C3POdoo
Copy link
Contributor

C3POdoo commented Oct 24, 2019

Dear @olilau,

Thank you for your contribution but the version 9.0 is no longer supported.
We only support the last 3 stable versions so no longer accepts patches into this branch.

We apology if we could not look at your request in time.
If the contribution still makes sense for the upper version, please let us know and do not hesitate to recreate one for the recent versions. We will try to check it as soon as possible.

This is an automated message.

@C3POdoo C3POdoo closed this Oct 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RD research & development, internal work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants