itpp-labs / misc-addons

Odoo Addons
https://itpp.dev
315 stars 587 forks source link

rollback issue. #824

Closed elliotxin closed 4 years ago

elliotxin commented 4 years ago

After I install this module in ODOO 11, a few months late, the database size becomes more than 10GB, because everything is storen in PostgreSQL now, If I want to make some database backup, it will take me so long time to do this, so I decided to roll back everything to filestore methods. After I change ir_attachment.location to file, the errors come out, like this:

Traceback (most recent call last):
  File "/home/elliot/odoo-dev/odoo11/odoo/addons/base/ir/ir_attachment.py", line 101, in _file_read
    r = base64.b64encode(open(full_path,'rb').read())
FileNotFoundError: [Errno 2] No such file or directory: '/home/elliot/.local/share/Odoo/filestore/orca/b8/b859f7412e47ac25d7bdc270d6ae08156fc61e77'
2019-10-11 15:33:38,819 16928 INFO orca odoo.addons.base.ir.ir_attachment: _read_file reading /home/elliot/.local/share/Odoo/filestore/orca/21/21cdf7b6948b5e79d8ffb9977dea2dae5d1ae8fa
Traceback (most recent call last):
  File "/home/elliot/odoo-dev/odoo11/odoo/fields.py", line 944, in __get__
    value = record.env.cache.get(record, self)
  File "/home/elliot/odoo-dev/odoo11/odoo/api.py", line 967, in get
    value = self._data[key][field][record._ids[0]]
KeyError: 52155

During handling of the above exception, another exception occurred:

This error will come and continued run in Odoo log one hour, after the error stop, the Odoo browse will prompt put another error message. So anyone can tell me how to fix these issues? Thanks a lot.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/81829725-rollback-issue?utm_campaign=plugin&utm_content=tracker%2F2288638&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F2288638&utm_medium=issues&utm_source=github).
yelizariev commented 4 years ago

Probably some record is deleted. You need to remove such attachment records manually.

I cannot help you more.

elliotxin commented 4 years ago

almost one hour, the Odoo browser was still running now.

Screen Shot 2019-10-12 at 12 00 19 AM

So I really don't know what records deleted before, because the database size now was 10GB, so it's very difficult for me to manually check the records, by the way, thanks for your replay.

elliotxin commented 4 years ago
Traceback (most recent call last):
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 944, in __get__
    value = record.env.cache.get(record, self)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/api.py", line 967, in get
    value = self._data[key][field][record._ids[0]]
KeyError: 48419

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/attachment_large_object/ir_attachment.py", line 72, in _compute_datas
    attach.datas = self._lobject_read(attach.store_fname, bin_size)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/attachment_large_object/ir_attachment.py", line 62, in _lobject_read
    lobj = self.lobject(self.env.cr, int(fname), 'rb')
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/attachment_large_object/ir_attachment.py", line 24, in lobject
    return cr._cnx.lobject(*args)
psycopg2.OperationalError: ERROR:  current transaction is aborted, commands ignored until end of transaction block

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 944, in __get__
    value = record.env.cache.get(record, self)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/api.py", line 967, in get
    value = self._data[key][field][record._ids[0]]
KeyError: 264

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 653, in _handle_exception
    return super(JsonRequest, self)._handle_exception(exception)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 312, in _handle_exception
    raise pycompat.reraise(type(exception), exception, sys.exc_info()[2])
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/tools/pycompat.py", line 87, in reraise
    raise value
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 695, in dispatch
    result = self._call_function(**self.params)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 344, in _call_function
    return checked_call(self.db, *args, **kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/service/model.py", line 97, in wrapper
    return f(dbname, *args, **kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 337, in checked_call
    result = self.endpoint(*a, **kw)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 939, in __call__
    return self.method(*args, **kw)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/http.py", line 517, in response_wrap
    response = f(*args, **kw)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/addons/web/controllers/main.py", line 934, in call_kw
    return self._call_kw(model, method, args, kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/addons/web/controllers/main.py", line 926, in _call_kw
    return call_kw(request.env[model], method, args, kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/api.py", line 689, in call_kw
    return call_kw_multi(method, model, args, kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/api.py", line 680, in call_kw_multi
    result = method(recs, *args, **kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/ir_attachment_force_storage/models.py", line 36, in write
    self._attachment_force_storage(storage_value)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/ir_attachment_force_storage/models.py", line 14, in _attachment_force_storage
    self.env['ir.attachment'].force_storage_previous(previous_value=previous_value)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/ir_attachment_force_storage/models.py", line 73, in force_storage_previous
    attach.write({'datas': attach.datas, 'url': attach.url})
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 948, in __get__
    self.determine_value(record)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 1061, in determine_value
    self.compute_value(recs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 1015, in compute_value
    self._compute_value(records)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 1006, in _compute_value
    getattr(records, self.compute)()
  File "/home/elliot/OrcaNation-dev/OrcaNation11/orca11/attachment_large_object/ir_attachment.py", line 74, in _compute_datas
    super(IrAttachment, attach)._compute_datas()
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/addons/base/ir/ir_attachment.py", line 192, in _compute_datas
    attach.datas = attach.db_datas
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 948, in __get__
    self.determine_value(record)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/fields.py", line 1051, in determine_value
    record._prefetch_field(self)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/models.py", line 2657, in _prefetch_field
    result = records.read([f.name for f in fs], load='_classic_write')
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/addons/base/ir/ir_attachment.py", line 426, in read
    self.check('read')
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/addons/base/ir/ir_attachment.py", line 333, in check
    self._cr.execute('SELECT res_model, res_id, create_uid, public FROM ir_attachment WHERE id IN %s', [tuple(self.ids)])
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/sql_db.py", line 155, in wrapper
    return f(self, *args, **kwargs)
  File "/home/elliot/OrcaNation-dev/OrcaNation11/OrcaNation/sql_db.py", line 232, in execute
    res = self._obj.execute(query, params)
psycopg2.InternalError: current transaction is aborted, commands ignored until end of transaction block

this is the final errors.