[go: nahoru, domu]

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: failed to reply RPC_EXTRA_INFO:the max length of data is 16777215 but got 127305012 #8768

Open
im-jinxinwang opened this issue Feb 1, 2023 · 20 comments
Assignees
Labels
checking check first if this issue occurred discuss

Comments

@im-jinxinwang
Copy link
Contributor
im-jinxinwang commented Feb 1, 2023

Current Behavior

This Error occurs:

2023/02/01` 07:18:32 [error] 50#50: *205966883 [lua] init.lua:841: phase_func(): failed to reply RPC_EXTRA_INFO: the max length of data is 16777215 but got 127305012, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/import/agent HTTP/1.1", host: "192.168.60.21", referrer: "http://192.168.60.21:32004/"
2023/02/01 07:18:32 [warn] 50#50: *205966883 [lua] plugin.lua:901: run_plugin(): ext-plugin-pre-req exits with http status code 503, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/import/agent HTTP/1.1", host: "192.168.60.21", referrer: "http://192.168.60.21:32004/"
172.30.65.0 - - [01/Feb/2023:07:18:32 +0000] 192.168.60.21 "POST /oam/2.0/tenant/import/agent HTTP/1.1" 503 671 1.215 "http://192.168.60.21:32004/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36" - - - "http://192.168.60.21"

Source code location:
https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua
image

Expected Behavior

This is the MAX_ DATA_ SIZE become a configurable variable.

Error Logs

2023/02/01 07:18:32 [error] 50#50: *205966883 [lua] init.lua:841: phase_func(): failed to reply RPC_EXTRA_INFO: the max length of data is 16777215 but got 127305012, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/import/agent HTTP/1.1", host: "192.168.60.21", referrer: "http://192.168.60.21:32004/"
2023/02/01 07:18:32 [warn] 50#50: *205966883 [lua] plugin.lua:901: run_plugin(): ext-plugin-pre-req exits with http status code 503, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/import/agent HTTP/1.1", host: "192.168.60.21", referrer: "http://192.168.60.21:32004/"
172.30.65.0 - - [01/Feb/2023:07:18:32 +0000] 192.168.60.21 "POST /oam/2.0/tenant/import/agent HTTP/1.1" 503 671 1.215 "http://192.168.60.21:32004/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36" - - - "http://192.168.60.21"

Steps to Reproduce

Use the ext-plugin-pre-req plugin,Upload large data content.

Environment

  • APISIX version (run apisix version): 3.1.0
  • Operating system (run uname -a): Linux apisix-5f5f44c88-ck2jr 3.10.0-862.el7.x86_64
  • OpenResty / Nginx version (run openresty -V or nginx -V): openresty/1.21.4.1
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):
@soulbird soulbird added discuss checking check first if this issue occurred labels Feb 6, 2023
@soulbird
Copy link
Contributor
soulbird commented Feb 7, 2023

@shreemaan-abhishek can you check this issue?

@shreemaan-abhishek
Copy link
Contributor

Sure, please assign it to me.

@shreemaan-abhishek
Copy link
Contributor

@WVenus we were unable to reproduce this bug. Are you using docker/kubernetes-based installation? If not, have you tried if this issue exists in docker/kubernetes based installation.

We tried reproducing the bug with the go-plugin-runner and the "say" plugin. Like so:

The route:

curl "http://127.0.0.1:9180/apisix/admin/routes/1" -H "X-API-KEY: edd1c9f034335f136f87ad84b625c8f1" -X PUT -d '
{
  "methods": ["POST"],
  "plugins": {
        "ext-plugin-pre-req": {
            "conf" : [
                {"name": "say", "value":"{\"body\":\"hello\"}"}
            ]
        }
    },
  "uri": "/anything/*",
  "upstream": {
    "type": "roundrobin",
    "nodes": {
      "[httpbin.org:80](http://httpbin.org/)": 1
    }
  }
}'

The curl post command:

curl -X POST "http://127.0.0.1:9080/anything/foo?arg=10" -F "image=@/Users/shreemaan-abhishek/Downloads/trip/IMG_4042.MOV"

We tried using payloads of various sizes, from KBs to several MBs. It did not fail for any size of the payload, could you report to us the payload size/length you were using?

This is what we found in the logs:

2023/02/10 09:43:41 [warn] 56#56: *66 [lua] init.lua:953: 2023-02-10T09:43:41.860Z	INFO	server/server.go:115	Client connected (unix), context: ngx.timer
2023/02/10 09:43:41 [warn] 56#56: *66 [lua] init.lua:953: 2023-02-10T09:43:41.860Z	INFO	server/server.go:115	Client connected (unix)
2023-02-10T09:43:41.861Z	INFO	server/server.go:131	receive rpc type: 1 data length: 120
2023-02-10T09:43:41.861Z	INFO	plugin/conf.go:98	prepare conf for plugin say, context: ngx.timer
2023/02/10 09:43:41 [warn] 56#56: *66 [lua] init.lua:953: 2023-02-10T09:43:41.871Z	INFO	server/server.go:131	receive rpc type: 2 data length: 476, context: ngx.timer
2023/02/10 09:43:41 [warn] 56#56: *66 [lua] init.lua:953: 2023-02-10T09:43:41.872Z	INFO	plugin/plugin.go:120	run plugin say, context: ngx.timer

@im-jinxinwang
Copy link
Contributor Author
im-jinxinwang commented Feb 13, 2023

@shreemaan-abhishek
I used kubernetes. You can try to upload data larger than 20M.
Do you test whether the uploaded data exceeds the MAX_DATA_SIZE variable?

@shreemaan-abhishek
Copy link
Contributor

Do you test whether the uploaded data exceeds the MAX_DATA_SIZE variable?

Sorry, I did not understand this, but I even tried with data of size 39MB. I did not fail.

@beginnerWJC
Copy link

l use apisix-java-plugin , the method requiredBody() default value is false ,l set true to find this issuce
image
image
the router :
{ "uri": "/oam/2.0/tenant/upload/vox", "name": "testfile", "methods": [ "POST" ], "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "TestPostFilter", "value": "" } ], "disable": false } }, "upstream_id": "435624104997946125", "status": 1 }
postman test:
image
log:
2023/02/14 01:56:10 [warn] 48#48: *3355 a client request body is buffered to a temporary file /usr/local/apisix/client_body_temp/0000000001, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/upload/vox HTTP/1.1", host: "192.168.60.21" 2023/02/14 01:56:10 [error] 48#48: *3355 [lua] init.lua:841: phase_func(): failed to reply RPC_EXTRA_INFO: the max length of data is 16777215 but got 24852340, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/upload/vox HTTP/1.1", host: "192.168.60.21" 2023/02/14 01:56:10 [warn] 48#48: *3355 [lua] plugin.lua:901: run_plugin(): ext-plugin-pre-req exits with http status code 503, client: 172.30.65.0, server: _, request: "POST /oam/2.0/tenant/upload/vox HTTP/1.1", host: "192.168.60.21" 172.30.65.0 - - [14/Feb/2023:01:56:10 +0000] 192.168.60.21 "POST /oam/2.0/tenant/upload/vox HTTP/1.1" 503 269 0.338 "-" "PostmanRuntime/7.28.4" - - - "http://192.168.60.21"

@beginnerWJC
Copy link

@im-jinxinwang
Copy link
Contributor Author

@shreemaan-abhishek
Can you reproduce the problem based on the information provided by @beginnerWJC?

@shreemaan-abhishek
Copy link
Contributor

@beginnerWJC could you please share the plugin that you are using?

@beginnerWJC
Copy link
beginnerWJC commented Feb 16, 2023

this is my test plugin
`package org.apache.apisix.plugin.runner.filter;

import java.util.Map;
import org.apache.apisix.plugin.runner.PostRequest;
import org.apache.apisix.plugin.runner.PostResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;

@component
public class TestPostFilter implements PluginFilter {

private final Logger logger = LoggerFactory.getLogger(TestPostFilter.class);

@Override
public String name() {
	return "TestPostFilter";
}

@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
	logger.info("TestPostFilter插件开始执行!");
	Map<String, String> headersMap = request.getUpstreamHeaders();
	logger.info("上游返回的headers:{}",JSON.toJSONString(headersMap));
	int statusCode = request.getUpstreamStatusCode();
	logger.info("上游返回的状态码为:{}",statusCode);
	if(statusCode == 204) {
		logger.info("修改上游的状态码为200");
		response.setStatusCode(200);
	}
	response.setHeader("apisix", "TestPostFilter");
	chain.postFilter(request, response);
}

@Override
public Boolean requiredBody() {
	return true;
}

}`
the router

{ "uri": "/oam/2.0/tenant/upload/vox", "name": "testfile", "methods": [ "POST" ], "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "TestPostFilter", "value": "" } ], "disable": false } }, "upstream_id": "435624104997946125", "status": 1 }
@shreemaan-abhishek l use apisix-java-plugin , the method requiredBody() default value is false ,l set true to find this issuce

@shreemaan-abhishek
Copy link
Contributor

@spacewander I was able to reproduce this issue, I think this is a valid bug and this should be fixed. Waiting for your confirmation.

@spacewander
Copy link
Member

This behavior is intended.
The size of length field is 3 bytes:

for i = 3, 1, -1 do

So only 16777215 bytes can be sent.

Is sending such a big body inevitable? Copy 16MB+ data between two languages per request is ineffective.

@beginnerWJC
Copy link
beginnerWJC commented Feb 21, 2023

@spacewander If it is a file upload interface,when the request body needs to be overwritten,It is easy to exceed 16M. So i hope expose an environment variable to set it.

@spacewander
Copy link
Member
spacewander commented Feb 22, 2023

I would suggest doing the body rewrite in Lua.
As for making the max length configurable, we need to extend the protocol and update the plugin runners and APISIX.
It is possible to do it, but doesn't have a high priority to support it (as it isn't a trivial job).

@xiaolajiyhy
Copy link

this is my test plugin `package org.apache.apisix.plugin.runner.filter;

import java.util.Map; import org.apache.apisix.plugin.runner.PostRequest; import org.apache.apisix.plugin.runner.PostResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import com.alibaba.fastjson.JSON;

@component public class TestPostFilter implements PluginFilter {

private final Logger logger = LoggerFactory.getLogger(TestPostFilter.class);

@Override
public String name() {
	return "TestPostFilter";
}

@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
	logger.info("TestPostFilter插件开始执行!");
	Map<String, String> headersMap = request.getUpstreamHeaders();
	logger.info("上游返回的headers:{}",JSON.toJSONString(headersMap));
	int statusCode = request.getUpstreamStatusCode();
	logger.info("上游返回的状态码为:{}",statusCode);
	if(statusCode == 204) {
		logger.info("修改上游的状态码为200");
		response.setStatusCode(200);
	}
	response.setHeader("apisix", "TestPostFilter");
	chain.postFilter(request, response);
}

@Override
public Boolean requiredBody() {
	return true;
}

}` the router

{ "uri": "/oam/2.0/tenant/upload/vox", "name": "testfile", "methods": [ "POST" ], "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "TestPostFilter", "value": "" } ], "disable": false } }, "upstream_id": "435624104997946125", "status": 1 } @shreemaan-abhishek l use apisix-java-plugin , the method requiredBody() default value is false ,l set true to find this issuce

为什么我 getUpstreamStatusCode 回返回36?

@shreemaan-abhishek
Copy link
Contributor

@xiaolajiyhy please use english.

@missence521
Copy link

此行为是有意为之。 长度字段的大小为 3 个字节:

for i = 3, 1, -1 do

因此只能发送16777215个字节。
发送这么大的数据是不可避免的吗?每次请求在两种语言之间复制 16MB 以上的数据是无效的。

业务场景确实有超过16m的情况,该怎么处理呢,目前可以改最大限制,但是带来的,就是使用这个插件就报https://github.com/apache/apisix-java-plugin-runner/issues/198,能给一个解决办法吗?期待您的回复

@zggg
Copy link
zggg commented May 27, 2024

Is there any progress? @shreemaan-abhishek

@charlesvhe
Copy link

we have same issue, any update?

@missence521
Copy link

The root cause of the final problem is that more than 16777215, with hdr buf 3 bits can not be put down, need to use 4 bits to store, to change init.lua, and the corresponding java plug-in acceptance and return methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checking check first if this issue occurred discuss
Projects
None yet
Development

No branches or pull requests

9 participants