timoninmaxim commented on code in PR #12412:
URL: https://github.com/apache/ignite/pull/12412#discussion_r2498543967
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -122,6 +123,10 @@ public static void registerIO() {
/** Exclusive lock for DDL operations. */
private final ReentrantReadWriteLock ddlLock = new
ReentrantReadWriteLock();
+ /** */
+ private final GridConcurrentHashSet<Index> fillingIdxs = new
GridConcurrentHashSet<>();
Review Comment:
Hashset is enough, let's change the collection under ddlLock
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -122,6 +123,10 @@ public static void registerIO() {
/** Exclusive lock for DDL operations. */
private final ReentrantReadWriteLock ddlLock = new
ReentrantReadWriteLock();
+ /** */
+ private final GridConcurrentHashSet<Index> fillingIdxs = new
GridConcurrentHashSet<>();
Review Comment:
Let's make it nullable
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -218,14 +223,26 @@ public Index createIndexDynamically(
IndexDefinition definition,
SchemaIndexCacheVisitor cacheVisitor
) {
- Index idx = createIndex(cctx, factory, definition);
+ IndexFactory dynamicFactory = (gcctx, indexDefinition) -> {
+ Index idx = factory.createIndex(gcctx, indexDefinition);
+
+ fillingIdxs.add(idx);
+ idx.markIndexRebuild(true);
+
+ return idx;
+ };
+
+ Index idx = createIndex(cctx, dynamicFactory, definition);
// Populate index with cache rows.
cacheVisitor.visit(row -> {
if (idx.canHandle(row))
idx.onUpdate(null, row, false);
});
+ fillingIdxs.remove(idx);
Review Comment:
What if index is deleted concurrently?
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -421,6 +438,11 @@ public Collection<Index> indexes(String cacheName) {
}
}
+ /** */
+ public boolean isFilling(Index idx) {
Review Comment:
Use flag in `index()`
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -218,14 +223,26 @@ public Index createIndexDynamically(
IndexDefinition definition,
SchemaIndexCacheVisitor cacheVisitor
) {
- Index idx = createIndex(cctx, factory, definition);
+ IndexFactory dynamicFactory = (gcctx, indexDefinition) -> {
+ Index idx = factory.createIndex(gcctx, indexDefinition);
+
+ fillingIdxs.add(idx);
+ idx.markIndexRebuild(true);
+
+ return idx;
+ };
+
+ Index idx = createIndex(cctx, dynamicFactory, definition);
// Populate index with cache rows.
cacheVisitor.visit(row -> {
if (idx.canHandle(row))
idx.onUpdate(null, row, false);
});
+ fillingIdxs.remove(idx);
Review Comment:
What if visitor throws an exception
##########
modules/core/src/main/java/org/apache/ignite/internal/cache/query/index/IndexProcessor.java:
##########
@@ -218,14 +223,26 @@ public Index createIndexDynamically(
IndexDefinition definition,
SchemaIndexCacheVisitor cacheVisitor
) {
- Index idx = createIndex(cctx, factory, definition);
+ IndexFactory dynamicFactory = (gcctx, indexDefinition) -> {
+ Index idx = factory.createIndex(gcctx, indexDefinition);
+
+ fillingIdxs.add(idx);
+ idx.markIndexRebuild(true);
Review Comment:
no need in this mark
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]