typedb / typedb-studio

TypeDB Studio (IDE)
https://typedb.com
Mozilla Public License 2.0
191 stars 44 forks source link

Schema editor loop fix #681

Closed jamesreprise closed 1 year ago

jamesreprise commented 1 year ago

What is the goal of this PR?

We've fixed a bug in the schema editor where it would enter a loop through a few layers of indirection. The core loop of this was:

  1. We load the constraints for a type B as a consequence of the user double clicking on it in the type browser.
  2. We load B's supertypes.
  3. B has a supertype A.
  4. We load the inheritables for A.
  5. As a part of loading the inheritables for A, we load its owned attribute types.
  6. A has an owned attribute, we'll call it name. B is a subtype of A, so it inherits name as well, becoming an owner type of name.
  7. We load the owner types for name, of which B is one.
  8. GOTO 2.

What are the changes implemented in this PR?

We've introduced the use of some AtomicBooleans, keeping track of what states are and aren't loaded. This also prevents us unnecessarily reloading data.

Before deciding to load a state, we check whether we've already loaded it. If we haven't, we add the fact that we have by flipping the relevant boolean. When any transaction is opened or a write transaction is performed, we flip all the booleans back to false to reflect the fact that our data is out of date.

typedb-bot commented 1 year ago

PR Review Checklist

Do not edit the content of this comment. The PR reviewer should simply update this comment by ticking each review item below, as they get completed.


Trivial Change

Code

Architecture