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

[BUG] Fix broken backward compatibility from 2.7 for IndexSorted field indices #10044

Closed
gashutos opened this issue Sep 14, 2023 · 0 comments · Fixed by #10045
Closed

[BUG] Fix broken backward compatibility from 2.7 for IndexSorted field indices #10044

gashutos opened this issue Sep 14, 2023 · 0 comments · Fixed by #10045
Assignees
Labels
bug Something isn't working rolling-upgrade Issues related to rolling upgrades v2.10.0 v3.0.0 Issues and PRs related to version 3.0.0

Comments

@gashutos
Copy link
Contributor

Description

Upgrade to OpenSearch 2.7 is breaking with change #6424 . Not for all scenarios but when any index contains IndexSorted field of either BYTE, BOOLEAN, SHORT, INTEGER, where the IndexSortField we created in prior version was upcasted to LONG for all above types, which was removed in #6424 to achieve better performance for sort queries.
The SortField for IndexSort is stored in SegmentInfo and that gets retained when index is migrating from old cluster to new 2.7 cluster, and hence in IndexWriter creation, Lucene throws Excetion because on 2.7, IndexWriteConfiguration has IndexSort with non-upcasted type while in SegmentInfo Lucene finds the same sort field with up-casted.

i.e, check below scenario, where Index sort is on Integer field, and the index is migrating from older version to 2.7 version, and on newer version, the IndexWriterCreation fails with IndexSort mismatch between IndexWriteIndexSort & Lucene segmentinfo contained indexsort.

"sort" : {
          "field" : "position",
          "order" : "desc"
        },
"position" : {
          "type" : "integer"
        },


Caused by: RemoteTransportException[[d3aea48e6d44f0fc824a9051f26d9969][:9300][internal:index/shard/recovery/prepare_translog]]; nested: IllegalArgumentException[cannot change previous indexSort=<sortednumeric: "position">! missingValue=-9223372036854775808 selector=MAX type=LONG (from segment=_8g9x(9.4.2):C61519:[indexSort=<sortednumeric: "position">! missingValue=-9223372036854775808 selector=MAX type=LONG]:[diagnostics={os=Linux, os.version=5.10.149-133.644.amzn2.aarch64, timestamp=1694560481039, mergeMaxNumSegments=-1, lucene.version=9.4.2, source=merge, os.arch=aarch64, java.runtime.version=11.0.18+10-LTS, mergeFactor=4, java.vendor=Amazon.com Inc.}]:[attributes={Lucene90StoredFieldsFormat.mode=BEST_SPEED}]:fieldInfosGen=36:dvGen=36 :softDel=27709 :id=5gdgx085ys6f3xyyb68rpx85c) to new indexSort=<sortednumeric: "position">! missingValue=-2147483648 selector=MAX type=INT];
Caused by: java.lang.IllegalArgumentException: cannot change previous indexSort=<sortednumeric: "position">! missingValue=-9223372036854775808 selector=MAX type=LONG (from segment=_8g9x(9.4.2):C61519:[indexSort=<sortednumeric: "position">! missingValue=-9223372036854775808 selector=MAX type=LONG]:[diagnostics={os=Linux, os.version=5.10.149-133.644.amzn2.aarch64, timestamp=1694560481039, mergeMaxNumSegments=-1, lucene.version=9.4.2, source=merge, os.arch=aarch64, java.runtime.version=11.0.18+10-LTS, mergeFactor=4, java.vendor=Amazon.com Inc.}]:[attributes={Lucene90StoredFieldsFormat.mode=BEST_SPEED}]:fieldInfosGen=36:dvGen=36 :softDel=27709 :id=5gdgx085ys6f3xyyb68rpx85c) to new indexSort=<sortednumeric: "position">! missingValue=-2147483648 selector=MAX type=INT
        at org.apache.lucene.index.IndexWriter.validateIndexSort(IndexWriter.java:1208)
        at org.apache.lucene.index.IndexWriter.<init>(IndexWriter.java:1119)
        at org.opensearch.index.engine.InternalEngine.createWriter(InternalEngine.java:2437)
        at org.opensearch.index.engine.InternalEngine.createWriter(InternalEngine.java:2425)
        at org.opensearch.index.engine.InternalEngine.<init>(InternalEngine.java:305)
        at org.opensearch.index.engine.InternalEngine.<init>(InternalEngine.java:223)
        at org.opensearch.index.engine.InternalEngineFactory.newReadWriteEngine(InternalEngineFactory.java:43)
        at org.opensearch.index.shard.IndexShard.innerOpenEngineAndTranslog(IndexShard.java:2286)
        at org.opensearch.index.shard.IndexShard.openEngineAndSkipTranslogRecovery(IndexShard.java:2259)
        at org.opensearch.indices.recovery.RecoveryTarget.lambda$prepareForTranslogOperations$1(RecoveryTarget.java:256)

This fix we need to release as patch release for >=2.7 versions.

@gashutos gashutos added bug Something isn't working untriaged labels Sep 14, 2023
@gashutos gashutos self-assigned this Sep 14, 2023
@gashutos gashutos added the rolling-upgrade Issues related to rolling upgrades label Sep 14, 2023
@gashutos gashutos changed the title [BUG] Fix broken backward comparibility from 2.7 for IndexSorted field indices [BUG] Fix broken backward compatibility from 2.7 for IndexSorted field indices Sep 14, 2023
@reta reta added v2.10.0 v3.0.0 Issues and PRs related to version 3.0.0 and removed untriaged labels Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rolling-upgrade Issues related to rolling upgrades v2.10.0 v3.0.0 Issues and PRs related to version 3.0.0
Projects
None yet
2 participants