diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java index 152f6584dd..37a1a2c755 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/AbstractBuilder.java @@ -40,7 +40,7 @@ public abstract class AbstractBuilder { - private final SchemaTransaction transaction; + protected final SchemaTransaction transaction; private final HugeGraph graph; public AbstractBuilder(SchemaTransaction transaction, HugeGraph graph) { diff --git a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java index 2521b1b1a7..713452e9ff 100644 --- a/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java +++ b/hugegraph-core/src/main/java/com/baidu/hugegraph/schema/builder/IndexLabelBuilder.java @@ -42,6 +42,7 @@ import com.baidu.hugegraph.schema.SchemaLabel; import com.baidu.hugegraph.schema.Userdata; import com.baidu.hugegraph.schema.VertexLabel; +import com.baidu.hugegraph.testutil.Whitebox; import com.baidu.hugegraph.type.HugeType; import com.baidu.hugegraph.type.define.Action; import com.baidu.hugegraph.type.define.CollectionType; @@ -182,10 +183,19 @@ public SchemaElement.TaskWithSchema createWithTask() { this.checkSchemaName(this.name); return this.lockCheckAndCreateSchema(type, this.name, name -> { + Id prefixedName = IdGenerator.of(type.string() + + "-" + name); + Object cache = Whitebox.invoke(this.transaction, "nameCache", new Class[]{Object.class}, + "get", prefixedName); IndexLabel indexLabel = this.indexLabelOrNull(name); if (indexLabel != null) { if (this.checkExist || !hasSameProperties(indexLabel)) { - throw new ExistedException(type, name); + Whitebox.invoke(this.transaction, "nameCache", new Class[]{Object.class}, + "invalidate", prefixedName); + IndexLabel indexLabel2 = this.indexLabelOrNull(name); + throw new ExistedException(type, name + + " cache-before-invalidate="+cache+ + ",indexLabel-after-invalidate="+indexLabel2); } return new SchemaElement.TaskWithSchema(indexLabel, IdGenerator.ZERO);