Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(pd-store): fix hstore backend core tests failure #2431

Merged
merged 17 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,8 @@
"Invalid cache implement: %s", cache.getClass());
return cache;
}

public void clearCache() {
this.caches.clear();
}

Check warning on line 156 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CacheManager.java#L155-L156

Added lines #L155 - L156 were not covered by tests
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@

private Cache<Id, Object> cache(String prefix, long capacity) {
// TODO: uncomment later - graph space
Pengzna marked this conversation as resolved.
Show resolved Hide resolved
//final String name = prefix + "-" + this.graph().spaceGraphName();
final String name = prefix + "-" + "";
final String name = prefix + "-" + this.graphName();

Check warning on line 89 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/backend/cache/CachedSchemaTransactionV2.java#L89

Added line #L89 was not covered by tests
// NOTE: must disable schema cache-expire due to getAllSchema()
return CacheManager.instance().cache(name, capacity);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.hugegraph.backend.id.Id;
import org.apache.hugegraph.backend.id.IdGenerator;
import org.apache.hugegraph.backend.tx.ISchemaTransaction;
import org.apache.hugegraph.backend.tx.SchemaTransaction;
import org.apache.hugegraph.job.SysJob;
import org.apache.hugegraph.schema.SchemaElement;
import org.apache.hugegraph.type.HugeType;
Expand Down Expand Up @@ -89,7 +88,7 @@
protected static void removeSchema(ISchemaTransaction tx,
SchemaElement schema) {
try {
Method method = SchemaTransaction.class
Method method = ISchemaTransaction.class
.getDeclaredMethod("removeSchema",
SchemaElement.class);
method.setAccessible(true);
Expand All @@ -109,10 +108,10 @@
* @param tx The update operation actual execute
* @param schema the schema to be updated
*/
protected static void updateSchema(SchemaTransaction tx,
protected static void updateSchema(ISchemaTransaction tx,
SchemaElement schema) {
try {
Method method = SchemaTransaction.class
Method method = ISchemaTransaction.class

Check warning on line 114 in hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java

View check run for this annotation

Codecov / codecov/patch

hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/job/schema/SchemaJob.java#L114

Added line #L114 was not covered by tests
.getDeclaredMethod("updateSchema",
SchemaElement.class);
method.setAccessible(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public ColumnIterator(String table, T results, byte[] keyBegin,
this.gotNext = false;
// QUESTION: Resetting the position may result in the caller being unable to
// retrieve the corresponding position.
// this.position = null;
this.position = null;
}
if (!ArrayUtils.isEmpty(this.keyBegin) ||
!ArrayUtils.isEmpty(this.keyEnd)) {
Expand Down Expand Up @@ -320,7 +320,7 @@ public boolean hasNext() {
} else {
// QUESTION: Resetting the position may result in the caller being unable to
// retrieve the corresponding position.
// this.position = null;
this.position = null;
}
return gotNext;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.hugegraph.HugeGraph;
import org.apache.hugegraph.HugeGraphParams;
import org.apache.hugegraph.backend.cache.CacheManager;
import org.apache.hugegraph.backend.store.BackendFeatures;
import org.apache.hugegraph.dist.RegisterUtil;
import org.apache.hugegraph.masterelection.GlobalMasterInfo;
Expand Down Expand Up @@ -90,6 +91,9 @@ public static void clear() {
public void setup() {
this.clearData();
this.clearSchema();
// QUESTION: here we should consider to clear cache
// but with this line of code, many ci will fail
// this.clearCache();
}

@After
Expand Down Expand Up @@ -146,6 +150,11 @@ private void clearSchema() {
});
}

private void clearCache() {
CacheManager cacheManager = CacheManager.instance();
cacheManager.clearCache();
}

protected void mayCommitTx() {
// Commit tx probabilistically for test
if (new Random().nextBoolean()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5195,6 +5195,7 @@ public void testScanEdgeInPaging() {
query.scan(String.valueOf(Long.MIN_VALUE),
String.valueOf(Long.MAX_VALUE));
} else {
// QUESTION:The query method may not be well adapted
query.scan(BackendTable.ShardSplitter.START,
BackendTable.ShardSplitter.END);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ public void testCopySchemaWithMultiGraphs() {

SchemaManager schema = g1.schema();

schema.propertyKey("id").asInt().create();
schema.propertyKey("name").asText().create();
schema.propertyKey("age").asInt().valueSingle().create();
schema.propertyKey("city").asText().create();
schema.propertyKey("weight").asDouble().valueList().create();
schema.propertyKey("id").asInt().checkExist(false).create();
schema.propertyKey("name").asText().checkExist(false).create();
schema.propertyKey("age").asInt().valueSingle().checkExist(false).create();
schema.propertyKey("city").asText().checkExist(false).create();
schema.propertyKey("weight").asDouble().valueList().checkExist(false).create();
schema.propertyKey("born").asDate().ifNotExist().create();
schema.propertyKey("time").asDate().ifNotExist().create();

Expand Down Expand Up @@ -211,8 +211,8 @@ public void testCopySchemaWithMultiGraphsWithConflict() {
g1.serverStarted(GlobalMasterInfo.master("server-g1c"));
g2.serverStarted(GlobalMasterInfo.master("server-g2c"));

g1.schema().propertyKey("id").asInt().create();
g2.schema().propertyKey("id").asText().create();
g1.schema().propertyKey("id").asInt().checkExist(false).create();
g2.schema().propertyKey("id").asText().checkExist(false).create();

Assert.assertThrows(ExistedException.class, () -> {
g2.schema().copyFrom(g1.schema());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ public boolean hasNext() {
return false;
}
// QUESTION: After `this.iterator.hasNext()` evaluates to false,
// no further attempts are made to reconstruct the iterator.
if (this.iterator != null) {
return this.iterator.hasNext();
// no further attempts should make to reconstruct the iterator.
if (this.iterator != null && this.iterator.hasNext()) {
return true;
}
long start = 0;
boolean debugEnabled = log.isDebugEnabled();
Expand Down
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,14 @@
<exclude>.repository/**</exclude>
<exclude>**/.flattened-pom.xml</exclude>
<!-- Test generated data -->
<exclude>**/rocksdb-*/**</exclude>
<exclude>**/rocksdb*/**</exclude>
<exclude>**/hbase-*/**</exclude>
<exclude>**/apache-cassandra-*/**</exclude>
<exclude>**/pid</exclude>
<exclude>**/tmp/**</exclude>
<!-- Sources generated by gRPC -->
<exclude>**/src/main/java/org/apache/hugegraph/pd/grpc/**</exclude>
<exclude>**/src/main/java/org/apache/hugegraph/store/grpc/**</exclude>
</excludes>
<consoleOutput>true</consoleOutput>
</configuration>
Expand Down
Loading