From 783a9c61350af50b664ec1c7259819a4e84df34c Mon Sep 17 00:00:00 2001 From: Zhangmei Li Date: Mon, 10 Jan 2022 18:00:44 +0800 Subject: [PATCH] debug exist index label Change-Id: Iecce2bd9482a136b85cdca9f01615a701fcf1af9 --- .../hugegraph/schema/builder/AbstractBuilder.java | 2 +- .../hugegraph/schema/builder/IndexLabelBuilder.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) 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);