vaticle / typedb

TypeDB: the polymorphic database powered by types
https://typedb.com
Mozilla Public License 2.0
3.72k stars 338 forks source link

Bug when defining a rule and undefining a type in the same transaction. #6994

Open krishnangovindraj opened 4 months ago

krishnangovindraj commented 4 months ago

Description

( Reported by @james-whiteside ) A null pointer exception is encountered in a schema transaction when 1. a rule is defined and 2. A type which is in the set of inferred types of some variable in the said rule is undefined.

Environment

  1. TypeDB distribution: Core
  2. TypeDB version: 2.26.6
  3. Environment: Mac
  4. Client and version: Any
  5. Other details:

Reproducible Steps

  1. Set up Define the schema (attached).

  2. Execute Execute the following queries in the same transaction. The bug is thrown when the transaction is committed.

    
    define
    rule transitive-location:
    when {
        (location: $parent-place, located: $child-place) isa locating;
        (location: $child-place, located: $x) isa locating;
    } then {
        (location: $parent-place, located: $x) isa locating;
    };

undefine indirect-locating sub locating;



3. Unexpected result
A null pointer exception is thrown and the commit is aborted.

## Expected result
Successfully commits the rule & undefines the type as would be if two separate transactions were used.

## Additional information

`TypeGraph::Statistics::outRelates(Stream<TypeVertex>)` receives a null from the stream.