Sergey Korotkov created IGNITE-26564:
----------------------------------------

             Summary: "Getting affinity for too old topology version" error on 
SQL query
                 Key: IGNITE-26564
                 URL: https://issues.apache.org/jira/browse/IGNITE-26564
             Project: Ignite
          Issue Type: Task
            Reporter: Sergey Korotkov
         Attachments: SqlAffinityHistoryTest.java

The error {{Getting affinity for too old topology version that is already out 
of history (try to increase 'IGNITE_AFFINITY_HISTORY_SIZE' system property)}} 
may occure on SQL query execution if query is started before the partitions 
exchange is completed for some just created cache mentioned in SQL statement.

It may be so if cache is created and queried from different threads and/or 
applications.

Reproducer attached.  

Initial topology version for cache is [topVer=3, minorTopVer=2] but query is 
started the moment the cluster topology is still [topVer=3, minorTopVer=1].

 
Full stack (from the thin client):

{noformat}
org.apache.ignite.IgniteCheckedException: Ignite failed to process request [3]: 
50000: Getting affinity for too old topology version that is already out of 
history (try to increase 'IGNITE_AFFINITY_HISTORY_SIZE' system property) 
[locNode=TcpDiscoveryNode [id=dc084b3f-7955-405a-b356-2d3b1c300001, 
consistentId=127.0.0.1:47501, addrs=ArrayList [127.0.0.1], sockAddrs=HashSet 
[/127.0.0.1:47501], discPort=47501, order=2, intOrder=2, loc=true, 
ver=2.18.0#20250930-sha1:52fdebf9, isClient=false], grp=SQL_TABLE, 
topVer=AffinityTopologyVersion [topVer=3, minorTopVer=1], 
lastAffChangeTopVer=AffinityTopologyVersion [topVer=3, minorTopVer=1], 
head=AffinityTopologyVersion [topVer=3, minorTopVer=2], 
history=[AffinityTopologyVersion [topVer=3, minorTopVer=2]], 
maxNonShallowHistorySize=25] (server status code [1])
        at 
org.apache.ignite.internal.util.IgniteUtils.cast(IgniteUtils.java:5018) 
~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.future.GridFutureAdapter.resolve(GridFutureAdapter.java:263)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.future.GridFutureAdapter.get0(GridFutureAdapter.java:194)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.future.GridFutureAdapter.get(GridFutureAdapter.java:144)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.TcpClientChannel.receive(TcpClientChannel.java:422)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.TcpClientChannel.service(TcpClientChannel.java:324)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ReliableChannel.lambda$service$0(ReliableChannel.java:213)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ReliableChannel.applyOnDefaultChannel(ReliableChannel.java:908)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ReliableChannel.applyOnDefaultChannel(ReliableChannel.java:854)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ReliableChannel.service(ReliableChannel.java:213)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ReliableChannel.service(ReliableChannel.java:194)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.GenericQueryPager.next(GenericQueryPager.java:107)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ClientQueryCursor$1.nextPage(ClientQueryCursor.java:93)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ClientQueryCursor$1.hasNext(ClientQueryCursor.java:76)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.ClientQueryCursor.getAll(ClientQueryCursor.java:47)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.processors.cache.SqlAffinityHistoryTest.lambda$testConcurrentCacheCreateAndSqlQueryFromThinClient$f431304b$1(SqlAffinityHistoryTest.java:79)
 ~[test-classes/:?]
        at 
org.apache.ignite.internal.util.lang.RunnableX.run(RunnableX.java:37) 
~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.testframework.GridTestUtils.lambda$runAsync$3(GridTestUtils.java:1212)
 ~[ignite-core-2.18.0-SNAPSHOT-tests.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.testframework.GridTestUtils.lambda$runAsync$4(GridTestUtils.java:1268)
 ~[ignite-core-2.18.0-SNAPSHOT-tests.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.testframework.GridTestUtils$7.call(GridTestUtils.java:1609) 
[ignite-core-2.18.0-SNAPSHOT-tests.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.testframework.GridTestThread.run(GridTestThread.java:88) 
[ignite-core-2.18.0-SNAPSHOT-tests.jar:2.18.0-SNAPSHOT]
Caused by: org.apache.ignite.internal.client.thin.ClientServerError: Ignite 
failed to process request [3]: 50000: Getting affinity for too old topology 
version that is already out of history (try to increase 
'IGNITE_AFFINITY_HISTORY_SIZE' system property) [locNode=TcpDiscoveryNode 
[id=dc084b3f-7955-405a-b356-2d3b1c300001, consistentId=127.0.0.1:47501, 
addrs=ArrayList [127.0.0.1], sockAddrs=HashSet [/127.0.0.1:47501], 
discPort=47501, order=2, intOrder=2, loc=true, 
ver=2.18.0#20250930-sha1:52fdebf9, isClient=false], grp=SQL_TABLE, 
topVer=AffinityTopologyVersion [topVer=3, minorTopVer=1], 
lastAffChangeTopVer=AffinityTopologyVersion [topVer=3, minorTopVer=1], 
head=AffinityTopologyVersion [topVer=3, minorTopVer=2], 
history=[AffinityTopologyVersion [topVer=3, minorTopVer=2]], 
maxNonShallowHistorySize=25] (server status code [1])
        at 
org.apache.ignite.internal.client.thin.TcpClientChannel.processNextMessage(TcpClientChannel.java:577)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
[2025-10-01T19:04:00,003]       at 
org.apache.ignite.internal.client.thin.TcpClientChannel.onMessage(TcpClientChannel.java:263)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.io.gridnioserver.GridNioClientConnection.onMessage(GridNioClientConnection.java:96)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
[DEBUG] at 
org.apache.ignite.internal.client.thin.io.gridnioserver.GridNioClientListener.onMessage(GridNioClientListener.java:56)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.client.thin.io.gridnioserver.GridNioClientListener.onMessage(GridNioClientListener.java:30)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
[select-thread-1]       at 
org.apache.ignite.internal.util.nio.GridNioFilterChain$TailFilter.onMessageReceived(GridNioFilterChain.java:279)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
[]      at 
org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
 ReliableChannel stopping
        at 
org.apache.ignite.internal.util.nio.GridNioCodecFilter.onMessageReceived(GridNioCodecFilter.java:116)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioFilterAdapter.proceedMessageReceived(GridNioFilterAdapter.java:109)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioServer$HeadFilter.onMessageReceived(GridNioServer.java:3730)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioFilterChain.onMessageReceived(GridNioFilterChain.java:175)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioServer$ByteBufferNioClientWorker.processRead(GridNioServer.java:1211)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.processSelectedKeysOptimized(GridNioServer.java:2518)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.bodyInternal(GridNioServer.java:2273)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.nio.GridNioServer$AbstractNioClientWorker.body(GridNioServer.java:1904)
 ~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at 
org.apache.ignite.internal.util.worker.GridWorker.run(GridWorker.java:125) 
~[ignite-core-2.18.0-SNAPSHOT.jar:2.18.0-SNAPSHOT]
        at java.base/java.lang.Thread.run(Thread.java:829) ~[?:?]

{noformat}



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

Reply via email to