On Mon, Nov 1, 2021 at 5:40 AM Ihor Radchenko <yantar92@gmail.com> wrote:
Thanks for reporting and providing the detailed backtrace!
Backtrace is really strange because cache is clearly updated upon
changing the file, but somehow somewhere a stale element is still
returned.

Given that you are using org-roam, the only suspect that may create
stale copies of cached elements is org-element-parse-buffer. The
attached patch is making sure that org-element-parse-buffer never tries
to reuse cache. Can you try the patch and see if it helps?

Applying the patch doesn't seem to have completely fixed the issue. 
Here's an error message I got after re-starting running the patch, below.

Before I go though, I thought it might be worth asking: how does one turn
off the cache? I'd like to see if that resolves not only this issue, but also the 
fact that saving this 700 line file takes 15 seconds now. 

Thanks for your help,
Greg

--- error message below ---
Warning (emacs): org-element--cache: Cached element has wrong parent in 211002_monthly.org. Resetting.
If this warning appears regularly, please report it to Org mode mailing list (M-x org-submit-bug-report).
The element is: "(headline (:raw-value \"Make sure Maia and I are on the same page regarding -- getting everything out of the attic and garage before Thursday!\" :begin 188 :end 315 :pre-blank 0 :contents-begin nil :contents-end nil :robust-begin nil :robust-end nil :level 2 :priority nil :tags nil :todo-keyword #(\"TODO\" 0 4 (face (org-todo org-todo org-level-2) wrap-prefix #(\"*** \" 0 1 ... 1 4 ...) line-prefix #(\"*\" 0 1 ...) fontified t)) :todo-type todo :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 188 :title \"Make sure Maia and I are on the same page regarding -- getting everything out of the attic and garage before Thursday!\" :mode nil :granularity element :cached t :parent (org-data (:begin 1 :contents-begin 1 :contents-end 93756 :end 93756 :robust-begin 44 :robust-end 93754 :post-blank 0 :post-affiliated 1 :path \"/Users/greg/org/roam-personal/211002_monthly.org\" :mode org-data :ID \"211002_080654\" :CATEGORY \"211002_monthly\" :cached t :org-element--cache-sync-key nil)) :org-element--cache-sync-key (29 . 188)))"
 The parent is: "(org-data (:begin 1 :contents-begin 1 :contents-end 93756 :end 93756 :robust-begin 44 :robust-end 93754 :post-blank 0 :post-affiliated 1 :path \"/Users/greg/org/roam-personal/211002_monthly.org\" :mode org-data :ID \"211002_080654\" :CATEGORY \"211002_monthly\" :cached t :org-element--cache-sync-key nil))"
 The real parent is: "(headline (:raw-value \"Monday\" :begin 112 :end 424 :pre-blank 0 :contents-begin 121 :contents-end 424 :robust-begin 123 :robust-end 422 :level 1 :priority nil :tags nil :todo-keyword nil :todo-type nil :post-blank 0 :footnote-section-p nil :archivedp nil :commentedp nil :post-affiliated 112 :title (#(\"Monday\" 0 6 (:parent #0))) :mode nil :granularity nil))"