[ 
https://issues.apache.org/jira/browse/IGNITE-26446?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18025002#comment-18025002
 ] 

 Kirill Sizov edited comment on IGNITE-26446 at 10/6/25 12:12 PM:
------------------------------------------------------------------

The issue is as follows:
- the script creates a table, a new pk index is created, then the script drops 
the table and the index is removed.
- for the whole script a single catalog version is created
However, for every change (command) an event is produced and a corresponding 
event handler is triggered. 

In our case - we are in the "onCatalogIndexCreateEvent" handler and trying to 
get from the catalog the index the event was triggered for. But since the 
catalog version was created for the whole batch, the catalog lacks intermediate 
state and we are failing on the attempt to get the index that was later dropped.

A possible fix is to create a new catalog event for every schema change 
command. if in our case "create table" had produced catalog version N and "drop 
table" - N+1, then there would have been no issues with processing the events


was (Author: JIRAUSER301198):
The issue is as follows:
- the script creates a table, a new pk index is created, then the script drops 
the table and the index is removed.
- for the whole script a single catalog version is created
However, for every change (command) an event is produced and a corresponding 
event handler is triggered. 

In our case - we are in the "onCatalogIndexCreateEvent" handler and trying to 
get from the catalog the index the event was triggered for. But since the 
catalog version was created for the whole batch, the catalog lacks intermediate 
state and we are failing on the attempt to get the index that was later dropped.



> Dropping a table right after creating leads to catalog update failure
> ---------------------------------------------------------------------
>
>                 Key: IGNITE-26446
>                 URL: https://issues.apache.org/jira/browse/IGNITE-26446
>             Project: Ignite
>          Issue Type: Task
>          Components: secondary indexes ai3
>            Reporter: Igor Gusev
>            Assignee:  Kirill Sizov
>            Priority: Major
>              Labels: ignite-3
>
> If you drop a table you just created, it causes issues with catalog updates.
> {code:java}
> sqlScript("" 
>                 + "CREATE TABLE Person (\n"
>                 + "  id int PRIMARY KEY,\n"
>                 + "  city_id int,\n"
>                 + "  name varchar,\n"
>                 + "  age int,\n"
>                 + "  company varchar\n"
>                 + ");" 
>                 + "DROP TABLE Person;"
>         
>         );{code}
> This causes warnings in log.
> {code:java}
> org.apache.ignite.internal.failure.StackTraceCapturingException: Failed to 
> apply catalog update.
>       at 
> org.apache.ignite.internal.failure.FailureManager.process(FailureManager.java:192)
>       at 
> org.apache.ignite.internal.failure.FailureManager.process(FailureManager.java:169)
>       at 
> org.apache.ignite.internal.catalog.CatalogManagerImpl$OnUpdateHandlerImpl.lambda$handle$1(CatalogManagerImpl.java:534)
>       at 
> java.base/java.util.concurrent.CompletableFuture.uniWhenComplete(CompletableFuture.java:859)
>       at 
> java.base/java.util.concurrent.CompletableFuture$UniWhenComplete.tryFire(CompletableFuture.java:837)
>       at 
> java.base/java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:506)
>       at 
> java.base/java.util.concurrent.CompletableFuture.postFire(CompletableFuture.java:610)
>       at 
> java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire$$$capture(CompletableFuture.java:791)
>       at 
> java.base/java.util.concurrent.CompletableFuture$UniRun.tryFire(CompletableFuture.java)
>       at 
> java.base/java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478)
>       at 
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
>       at 
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
>       at java.base/java.lang.Thread.run(Thread.java:829)
> Caused by: java.util.concurrent.CompletionException: 
> java.lang.AssertionError: indexId=21, catalogVersion=3
>       at 
> java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:331)
>       at 
> java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:743)
>       at 
> java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:731)
>       at 
> java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2114)
>       at 
> org.apache.ignite.internal.event.AbstractEventProducer.fireEvent(AbstractEventProducer.java:99)
>       at 
> org.apache.ignite.internal.catalog.CatalogManagerImpl.access$000(CatalogManagerImpl.java:81)
>       at 
> org.apache.ignite.internal.catalog.CatalogManagerImpl$OnUpdateHandlerImpl.handle(CatalogManagerImpl.java:519)
>       at 
> org.apache.ignite.internal.catalog.CatalogManagerImpl$OnUpdateHandlerImpl.handle(CatalogManagerImpl.java:486)
>       at 
> org.apache.ignite.internal.catalog.storage.UpdateLogImpl$UpdateListener.onUpdate(UpdateLogImpl.java:348)
>       at 
> org.apache.ignite.internal.metastorage.server.Watch.onUpdate(Watch.java:67)
>       at 
> org.apache.ignite.internal.metastorage.server.WatchProcessor.performWatchesNotifications(WatchProcessor.java:317)
>       at 
> org.apache.ignite.internal.metastorage.server.WatchProcessor.lambda$notifyWatchesInternal$7(WatchProcessor.java:264)
>       at 
> org.apache.ignite.internal.util.IgniteUtils.inBusyLockAsync(IgniteUtils.java:941)
>       at 
> org.apache.ignite.internal.metastorage.server.WatchProcessor.inBusyLockAsync(WatchProcessor.java:193)
>       at 
> org.apache.ignite.internal.metastorage.server.WatchProcessor.lambda$enqueue$2(WatchProcessor.java:239)
>       at 
> java.base/java.util.concurrent.CompletableFuture$UniCompose.tryFire(CompletableFuture.java:1072)
>       ... 4 more
> Caused by: java.lang.AssertionError: indexId=21, catalogVersion=3
>       at 
> org.apache.ignite.internal.table.distributed.index.IndexMeta.of(IndexMeta.java:86)
>       at 
> org.apache.ignite.internal.table.distributed.index.IndexMetaStorage.lambda$onCatalogIndexCreateEvent$0(IndexMetaStorage.java:222)
>       at 
> org.apache.ignite.internal.table.distributed.index.IndexMetaStorage.lambda$createAndSaveIndexMetaToMetastore$16(IndexMetaStorage.java:488)
>       at 
> java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1908)
>       at 
> org.apache.ignite.internal.table.distributed.index.IndexMetaStorage.createAndSaveIndexMetaToMetastore(IndexMetaStorage.java:488)
>       at 
> org.apache.ignite.internal.table.distributed.index.IndexMetaStorage.onCatalogIndexCreateEvent(IndexMetaStorage.java:219)
>       at 
> org.apache.ignite.internal.event.EventListener.lambda$fromFunction$1(EventListener.java:64)
>       at 
> org.apache.ignite.internal.event.AbstractEventProducer.fireEvent(AbstractEventProducer.java:88)
>  {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to