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

After this commit, the core tests of hstore expect the following tests to fail:

```text
Failures:
  EdgeCoreTest.testScanEdgeInPaging:5214 expected:<18> but was:<0>
  MultiGraphsTest.testCopySchemaWithMultiGraphs:121
  VertexCoreTest.testAddOlapRangeAndOlapSecondaryProperties:2491 expected:<1> but was:<0>
  VertexCoreTest.testAddOlapRangeProperties:2344 expected:<1> but was:<0>
  VertexCoreTest.testAddOlapSecondaryProperties:2254 expected:<1> but was:<0>
  VertexCoreTest.testQueryOlapRangeAndRegularSecondaryProperties:2638 expected:<1> but was:<0>
  VertexCoreTest.testQueryOlapWithUpdates:2725 expected:<1> but was:<0>
  VertexCoreTest.testScanVertexInPaging:7606 expected:<10> but was:<1>
Errors:
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithMoreFields:3912 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithMoreFieldsInPage:4131 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithPrefix:3704 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithPrefixInPage:3800 » HgStoreClient
  EdgeCoreTest.testQueryOutEdgesOfVertexBySortkeyWithRange:3607 » HgStoreClient ...
  MultiGraphsTest.testCreateGraphWithSameNameDifferentBackends:289->openGraphWithBackend:381 » Runtime
  RamTableTest.testReloadAndQuery:112 » Huge Failed to load ramtable
  RamTableTest.testReloadAndQueryWithBigVertex:369 » Huge Failed to load ramtabl...
  RamTableTest.testReloadAndQueryWithMultiEdges:239 » Huge Failed to load ramtab...
  RamTableTest.testReloadAndQueryWithProperty:444 » Huge Failed to load ramtable
  RamTableTest.testReloadFromFileAndQuery:159 » Huge Failed to load ramtable
  VertexCoreTest.testQueryByPropertyInPageWithLimitGtPageSize:8337 » IllegalArgument
  VertexCoreTest.testQueryByRangeIndexInPage:8568 » IllegalArgument Undefined in...
  VertexCoreTest.testQueryBySingleRangePropertyInPage:8423 » IllegalArgument Und...
```

---------

Co-authored-by: VGalaxies <vgalaxies@apache.org>
This commit is contained in:
Peng Junzhi 2024-02-27 17:42:59 +08:00 committed by GitHub
parent 198f7004ae
commit 6db8b08f14
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 35 additions and 19 deletions

View File

@ -150,4 +150,8 @@ public class CacheManager {
"Invalid cache implement: %s", cache.getClass());
return cache;
}
public void clearCache() {
this.caches.clear();
}
}

View File

@ -86,8 +86,7 @@ public class CachedSchemaTransactionV2 extends SchemaTransactionV2 {
private Cache<Id, Object> cache(String prefix, long capacity) {
// TODO: uncomment later - graph space
//final String name = prefix + "-" + this.graph().spaceGraphName();
final String name = prefix + "-" + "";
final String name = prefix + "-" + this.graphName();
// NOTE: must disable schema cache-expire due to getAllSchema()
return CacheManager.instance().cache(name, capacity);
}

View File

@ -23,7 +23,6 @@ import java.lang.reflect.Method;
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;
@ -89,7 +88,7 @@ public abstract class SchemaJob extends SysJob<Object> {
protected static void removeSchema(ISchemaTransaction tx,
SchemaElement schema) {
try {
Method method = SchemaTransaction.class
Method method = ISchemaTransaction.class
.getDeclaredMethod("removeSchema",
SchemaElement.class);
method.setAccessible(true);
@ -109,10 +108,10 @@ public abstract class SchemaJob extends SysJob<Object> {
* @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
.getDeclaredMethod("updateSchema",
SchemaElement.class);
method.setAccessible(true);

View File

@ -247,7 +247,7 @@ public class HstoreSessionsImpl extends HstoreSessions {
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)) {
@ -320,7 +320,7 @@ public class HstoreSessionsImpl extends HstoreSessions {
} 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;
}

View File

@ -21,6 +21,7 @@ import java.util.Random;
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;
@ -90,6 +91,9 @@ public class BaseCoreTest {
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
@ -146,6 +150,11 @@ public class BaseCoreTest {
});
}
private void clearCache() {
CacheManager cacheManager = CacheManager.instance();
cacheManager.clearCache();
}
protected void mayCommitTx() {
// Commit tx probabilistically for test
if (new Random().nextBoolean()) {

View File

@ -5195,6 +5195,7 @@ public class EdgeCoreTest extends BaseCoreTest {
query.scan(String.valueOf(Long.MIN_VALUE),
String.valueOf(Long.MAX_VALUE));
} else {
// QUESTIONThe query method may not be well adapted
query.scan(BackendTable.ShardSplitter.START,
BackendTable.ShardSplitter.END);
}

View File

@ -92,11 +92,11 @@ public class MultiGraphsTest extends BaseCoreTest {
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();
@ -211,8 +211,8 @@ public class MultiGraphsTest extends BaseCoreTest {
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());

View File

@ -195,9 +195,9 @@ class KvPageScanner implements KvCloseableIterator<Kv>, HgPageSize, HgSeekAble {
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();

View File

@ -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>