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] Zstd new codec is a breaking change for kNN plugin #7012

Closed
martin-gaievski opened this issue Apr 5, 2023 · 17 comments · Fixed by #7014 or #7037
Closed

[BUG] Zstd new codec is a breaking change for kNN plugin #7012

martin-gaievski opened this issue Apr 5, 2023 · 17 comments · Fixed by #7014 or #7037
Labels
bug Something isn't working

Comments

@martin-gaievski
Copy link
Member

Describe the bug
Plugins cannot continue to use existing approach and register CodecServiceFactory and cluster is crushing in runtime (compile time is ok). Example is kNN plugin, error on cluster start:

https://github.com/opensearch-project/k-NN/actions/runs/4614564115/jobs/8170344936#step:9:1265

»  java.lang.IllegalStateException: existing codec service factory already overridden in: org.opensearch.index.codec.customcodecs.CustomCodecPlugin attempting to override again by: org.opensearch.knn.plugin.KNNPlugin
»  	at org.opensearch.index.engine.EngineConfigFactory.<init>(EngineConfigFactory.java:107) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.index.engine.EngineConfigFactory.<init>(EngineConfigFactory.java:63) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.indices.IndicesService.getEngineConfigFactory(IndicesService.java:913) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.indices.IndicesService.createIndexService(IndicesService.java:874) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.indices.IndicesService.createIndex(IndicesService.java:775) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.indices.IndicesService.createIndex(IndicesService.java:209) ~[opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]
»  	at org.opensearch.indices.cluster.IndicesClusterStateService.createIndices(IndicesClusterStateService.java:539) [opensearch-3.0.0-SNAPSHOT.jar:3.0.0-SNAPSHOT]

Code on kNN side that is registering CustomServiceFactory:
https://github.com/opensearch-project/k-NN/blob/main/src/main/java/org/opensearch/knn/plugin/KNNPlugin.java#L271-L276

To Reproduce
Steps to reproduce the behavior:

  1. Get main branch from k-NN repo
  2. Do ./gradlew run

Expected behavior
There should be alternative way of either enabling/disabling plugins or for plugin to register their CustomServiceFactory.

Plugins
distribution build, k-NN is included

Additional context
Core change introduced in #3577

Part of PR that is registering new factory: https://github.com/opensearch-project/OpenSearch/pull/3577/files#diff-629964cdbeae1039851179519fc3e3d3cc45e8329d208dd9f2b7034537675262R38

Core code where the check for only one factory is happening: https://github.com/opensearch-project/OpenSearch/blob/main/server/src/main/java/org/opensearch/index/engine/EngineConfigFactory.java#L79

@martin-gaievski martin-gaievski added bug Something isn't working untriaged labels Apr 5, 2023
@reta
Copy link
Collaborator

reta commented Apr 5, 2023

Thanks @martin-gaievski , this is very interesting - the ZSTD (basically, additional codecs) is the sandbox plugin and should not be bundled/installed by default.

@reta
Copy link
Collaborator

reta commented Apr 5, 2023

Ah ... I found it https://github.com/opensearch-project/OpenSearch/blob/main/distribution/build.gradle#L242

if (VersionProperties.isOpenSearchSnapshot()) {
 ...
}

@martin-gaievski
Copy link
Member Author

Thanks @martin-gaievski , this is very interesting - the ZSTD (basically, additional codecs) is the sandbox plugin and should not be bundled/installed by default.

this is a module, not a plugin.

Ah ... I found it https://github.com/opensearch-project/OpenSearch/blob/main/distribution/build.gradle#L242

if (VersionProperties.isOpenSearchSnapshot()) {
 ...
}

right, for module it's different.

@reta
Copy link
Collaborator

reta commented Apr 5, 2023

@mulugetam I think we should move custom-codecs from sandbox/modules to sandbox/plugins, at least for for now, otherwise the way modules are installed breaks other plugins.

@mulugetam
Copy link
Contributor

@reta @martin-gaievski Will create a new PR that does just that.

@reta
Copy link
Collaborator

reta commented Apr 5, 2023

@mulugetam already did

@navneet1v
Copy link
Contributor

@mulugetam I think we should move custom-codecs from sandbox/modules to sandbox/plugins, at least for for now, otherwise the way modules are installed breaks other plugins.

@reta This should work once custom-codecs is moved to Plugins folder in sandbox.

From feature standpoint this looks an interesting feature. Once the change is made we should also think about how other plugins which provide their own codec can take advantage of this new zstd codec. Happy to discuss this more on a separate issue or this same issue.

Another point, did we consider adding this codec as part of Lucene itself?

@reta
Copy link
Collaborator

reta commented Apr 5, 2023

Thanks @navneet1v

Another point, did we consider adding this codec as part of Lucene itself?

Yes, it is actually the reverse: codec was suggested to Lucene first and rejected due to JNI concerns, see please apache/lucene#439

@navneet1v
Copy link
Contributor

Thanks @navneet1v

Another point, did we consider adding this codec as part of Lucene itself?

Yes, it is actually the reverse: codec was suggested to Lucene first and rejected due to JNI concerns, see please apache/lucene#439

Thanks @reta . I was not aware of this.

@kotwanikunal
Copy link
Member

@martin-gaievski The fix has been merged in and backported. Please reopen if the issue still exists.

@dblock
Copy link
Member

dblock commented Apr 5, 2023

Do I understand correctly that to enable ZSTD as is I would have to disable k-nn? Do we have an issue open for the long term fix?

@navneet1v
Copy link
Contributor

navneet1v commented Apr 5, 2023

Do I understand correctly that to enable ZSTD as is I would have to disable k-nn? Do we have an issue open for the long term fix?

There is no issue opened, but we need that. Atleast we got to know about this feature today morning, hence we have not thought about it.

Also, another thing is this is a custom codec, I believe that there should be an index setting which tells this codec should be enabled or not for an index, rather than applying to all indices. Atleast to my knowledge I don't see that in this code change.

@dblock I hope this ans your question.

@navneet1v navneet1v reopened this Apr 5, 2023
@mulugetam
Copy link
Contributor

@dblock Yes, I think we should have an issue open for that. @navneet1v User has to set it explicitly: index.codec: ZSTD.

@dblock
Copy link
Member

dblock commented Apr 6, 2023

@mulugetam will you please create one for supporting multiple?
@navneet1v will you please create one for the index setting?

@navneet1v
Copy link
Contributor

Hi @mulugetam
As per quick look in the code I cannot see the setting index.codec:ZTSD. Because that has been the case the k-NN build shouldn't not fail. But I can see same setting on K-NN plugin where K-NN tries to give the customer codec factory only if the index.knn setting is true(code).

@navneet1v
Copy link
Contributor

@dblock issue created for supporting zstd codec for K-NN plugin: #7032

I created a generic issue which can allow other plugins who uses the CodecServiceFactory to take advantage of improvement done in Codec of OpenSearch.

mulugetam added a commit to mulugetam/OpenSearch that referenced this issue Apr 6, 2023
…NODICT.

  - addresses opensearch-project#7012

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
mulugetam added a commit to mulugetam/OpenSearch that referenced this issue Apr 6, 2023
  - addresses opensearch-project#7012

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
@mulugetam
Copy link
Contributor

@dblock @navneet1v #7037.

@dbwiddis dbwiddis removed the untriaged label Apr 7, 2023
dblock pushed a commit that referenced this issue Apr 13, 2023
* Fix: enable ZSTD codec only if index.codec is set to ZSTD.

  - addresses #7012

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Removed custom CodecService and CodecServiceFactory classes.

  - Removed custom classes for CodecService and CodecServiceFactory.
  - Also removed PerFieldMappingPostingFormatCodec -- not required.
  - Added documentation.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Bump zstd-jni version from 1.5.4-1 to 1.5.5-1.

  - Zstandard version 1.5.5 contains a bug fix for a rare corruption error
    described here: https://github.com/facebook/zstd/releases/tag/v1.5.5. The
    zstd-jni version we use here, 1.5.5-1, uses Zstandard v1.5.5.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

---------

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
opensearch-trigger-bot bot pushed a commit that referenced this issue Apr 13, 2023
* Fix: enable ZSTD codec only if index.codec is set to ZSTD.

  - addresses #7012

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Removed custom CodecService and CodecServiceFactory classes.

  - Removed custom classes for CodecService and CodecServiceFactory.
  - Also removed PerFieldMappingPostingFormatCodec -- not required.
  - Added documentation.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Bump zstd-jni version from 1.5.4-1 to 1.5.5-1.

  - Zstandard version 1.5.5 contains a bug fix for a rare corruption error
    described here: https://github.com/facebook/zstd/releases/tag/v1.5.5. The
    zstd-jni version we use here, 1.5.5-1, uses Zstandard v1.5.5.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

---------

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
(cherry picked from commit 569e90c)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
reta pushed a commit that referenced this issue Apr 13, 2023
…7149)

* Fix: enable ZSTD codec only if index.codec is set to ZSTD.

  - addresses #7012



* Removed custom CodecService and CodecServiceFactory classes.

  - Removed custom classes for CodecService and CodecServiceFactory.
  - Also removed PerFieldMappingPostingFormatCodec -- not required.
  - Added documentation.



* Bump zstd-jni version from 1.5.4-1 to 1.5.5-1.

  - Zstandard version 1.5.5 contains a bug fix for a rare corruption error
    described here: https://github.com/facebook/zstd/releases/tag/v1.5.5. The
    zstd-jni version we use here, 1.5.5-1, uses Zstandard v1.5.5.



---------


(cherry picked from commit 569e90c)

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
austintlee pushed a commit to austintlee/OpenSearch that referenced this issue Apr 28, 2023
…rch-project#7037)

* Fix: enable ZSTD codec only if index.codec is set to ZSTD.

  - addresses opensearch-project#7012

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Removed custom CodecService and CodecServiceFactory classes.

  - Removed custom classes for CodecService and CodecServiceFactory.
  - Also removed PerFieldMappingPostingFormatCodec -- not required.
  - Added documentation.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

* Bump zstd-jni version from 1.5.4-1 to 1.5.5-1.

  - Zstandard version 1.5.5 contains a bug fix for a rare corruption error
    described here: https://github.com/facebook/zstd/releases/tag/v1.5.5. The
    zstd-jni version we use here, 1.5.5-1, uses Zstandard v1.5.5.

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>

---------

Signed-off-by: Mulugeta Mammo <mulugeta.mammo@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment