pfalcon / zim-desktop-wiki-markdown

pfalcon's fork of Zim desktop wiki project - quick Markdown format support for notebooks, usability improvements, etc. Everything WIP.
http://zim-wiki.org
GNU General Public License v2.0
30 stars 3 forks source link

sqlite3 thread access rules violation error #1

Open pfalcon opened 3 years ago

pfalcon commented 3 years ago

Originally posted as https://github.com/zim-desktop-wiki/zim-desktop-wiki/issues/1285


I've just got such an error (git master, e5cadf37c60b663dcb8d5f641fe96dd0d9dd2fe6):

ERROR: Error in background save
Traceback (most recent call last):
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/notebook.py", line 532, in _store_page_async_thread_main
    page._store_tree(parsetree)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/page.py", line 507, in _store_tree
    lines = dumper.dump(tree, file_output=True)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/zim_markdown.py", line 733, in dump
    return TextDumper.dump(self, tree)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 1180, in dump
    tree.visit(self)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 560, in visit
    self._visit(visitor, self._etree.getroot())
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 571, in _visit
    self._visit(visitor, child) # recurs
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 571, in _visit
    self._visit(visitor, child) # recurs
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 576, in _visit
    visitor.append(node.tag, node.attrib, node.text)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/__init__.py", line 1254, in append
    strings = method(tag, attrib, [self.encode_text(tag, text)])
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/formats/zim_markdown.py", line 765, in dump_link
    linked_path = self.notebook.pages.resolve_link(self.page, HRef.new_from_wiki_link(href))
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/index/pages.py", line 753, in resolve_link
    id, pagename = self._pages.resolve_link(source, href)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/index/pages.py", line 366, in resolve_link
    parent, parent_id, names = self._resolve_link(source, href, ignore_link_placeholders, source_id)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/index/pages.py", line 377, in _resolve_link
    start_id = self.get_page_id(start)
  File "/mnt/hdd/projects-3rdparty/PIM/zim-desktop-wiki/zim/notebook/index/pages.py", line 359, in get_page_id
    'SELECT id FROM pages WHERE name=?', (pagename.name,)
sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in that same thread. The object was created in thread id 140627211577152 and this is thread id 140626983110400.

What I've being doing is a pretty common and natural action sequence:

  1. Created a new subpage of a page.
  2. Switched to parent page and cut a subsection of it to a clipboard.
  3. Was about to switch to new subpage and paste it.

I couldn't do p.3 at this time, switching to any other page but the current page didn't work. I then pasted the content back to the original page and pressed Ctrl+S (the key combo I use the most with Zim). Then it all recovered and I retried the operation.

But this all indeed sounds scary, a random user could lose data in such a way.

pfalcon commented 3 years ago

Moved to this repo, as formally error is triggered by a call from zim/formats/zim_markdown.py, maintained in this repo.