SlashDB returns 502 长 URL
SlashDB returns 502 on long URL
我正在使用 SlashDB 在 MySQL 后端上对 REST 接口进行分层。大多数情况下,我通过 'SQL Pass-thru' 功能定义查询。我们正在使用这个系统来记录来自各个测试站的测试数据。
将测试数据发送到数据库时,一旦 URL 超过一定长度(大约 2K 的数据),SlashDB 似乎就会阻塞。返回的错误是“502”,这很奇怪,因为 URI 太长通常 returns 一个“414”。当我直接在MySQL中尝试查询时,没有问题。
table 定义如下:
CREATE TABLE `test_result` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`test_instance_id` bigint(20) unsigned NOT NULL,
`test_instance_test_station_id` varchar(15) NOT NULL,
`test_instance_unit_sn` varchar(30) NOT NULL,
`test_instance_contact_address_id` int(2) NOT NULL,
`testStep` varchar(45) DEFAULT NULL,
`testData` blob,
`externalDataLink` text,
PRIMARY KEY (`id`),
KEY `fk_test_result_test_instance1_idx` (`test_instance_id`,`test_instance_test_station_id`,`test_instance_unit_sn`,`test_instance_contact_address_id`),
CONSTRAINT `fk_test_result_test_instance1` FOREIGN KEY (`test_instance_id`, `test_instance_test_station_id`, `test_instance_unit_sn`, `test_instance_contact_address_id`) REFERENCES `test_instance` (`id`, `test_station_id`, `unit_sn`, `contact_address_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
这里是 URL(大数据被截断):
/post-test-result/testId/116/locationId/99/stationId/BO-01/sn/991807000003/stepName/test2/testData/[这里有2K的数据]/dataUrl/bye2.json?limit=29
通过'SQL Pass-thru'定义的查询:
插入 test_result(test_instance_id、test_instance_contact_address_id、test_instance_test_station_id、test_instance_unit_sn、testStep、testData、externalDataLink)值
(:testId, :locationId, :stationId, :sn, :stepName, :testData, :dataUrl);
有人能解释一下吗?
尝试更新 /etc/nginx/nginx.conf
文件中的 uwsgi 缓冲区值
server {
uwsgi_buffer_size 8k;
uwsgi_buffers 4 8k;
uwsgi_busy_buffers_size 16k;
# ... #
和 /etc/slashdb/slashdb.ini
文件,在 [uwsgi]
部分的末尾添加 buffer-size = 32768
。 uwsgi 部分应该如下所示:
# uWSGI config for service scriptm starts uWSGI as a daemon
[uwsgi]
socket = 127.0.0.1:8001
virtualenv = /opt/slashdb
daemonize = /var/log/slashdb/uwsgi.log
log-maxsize = 20971520
master = true
enable-threads = true
single-interpreter = true
lazy-apps = true
processes = 1
threads = 2
paste = config:%p
paste-logger = %p
buffer-size = 32768
然后重启服务:
sudo service slashdb stop
sudo service slashdb start
sudo service nginx restart
BTW SlashDB 目前不反映 BLOB 类型,但如果您将 testData
列类型更改为 text
,那么您将能够在 Data Discovery 中使用 POST 方法来接缝更适合您的用例。
使用 curl 它将是
curl -v 'http://slashdb.reshareu/db/testing/test_result.json' \
-X POST \
-H 'apikey: your-api-key-here' \
-H 'content-type: application/json' \
--data '{
"test_instance_test_station_id": "BO-01",
"test_instance_contact_address_id": 99,
"test_instance_unit_sn": "991807000003",
"testStep": "test2",
"externalDataLink": "bye2",
"test_instance_id": 116,
"testData": "Very long yata, yata, yata..."
}'
我正在使用 SlashDB 在 MySQL 后端上对 REST 接口进行分层。大多数情况下,我通过 'SQL Pass-thru' 功能定义查询。我们正在使用这个系统来记录来自各个测试站的测试数据。
将测试数据发送到数据库时,一旦 URL 超过一定长度(大约 2K 的数据),SlashDB 似乎就会阻塞。返回的错误是“502”,这很奇怪,因为 URI 太长通常 returns 一个“414”。当我直接在MySQL中尝试查询时,没有问题。
table 定义如下:
CREATE TABLE `test_result` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`test_instance_id` bigint(20) unsigned NOT NULL,
`test_instance_test_station_id` varchar(15) NOT NULL,
`test_instance_unit_sn` varchar(30) NOT NULL,
`test_instance_contact_address_id` int(2) NOT NULL,
`testStep` varchar(45) DEFAULT NULL,
`testData` blob,
`externalDataLink` text,
PRIMARY KEY (`id`),
KEY `fk_test_result_test_instance1_idx` (`test_instance_id`,`test_instance_test_station_id`,`test_instance_unit_sn`,`test_instance_contact_address_id`),
CONSTRAINT `fk_test_result_test_instance1` FOREIGN KEY (`test_instance_id`, `test_instance_test_station_id`, `test_instance_unit_sn`, `test_instance_contact_address_id`) REFERENCES `test_instance` (`id`, `test_station_id`, `unit_sn`, `contact_address_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8
这里是 URL(大数据被截断):
/post-test-result/testId/116/locationId/99/stationId/BO-01/sn/991807000003/stepName/test2/testData/[这里有2K的数据]/dataUrl/bye2.json?limit=29
通过'SQL Pass-thru'定义的查询:
插入 test_result(test_instance_id、test_instance_contact_address_id、test_instance_test_station_id、test_instance_unit_sn、testStep、testData、externalDataLink)值 (:testId, :locationId, :stationId, :sn, :stepName, :testData, :dataUrl);
有人能解释一下吗?
尝试更新 /etc/nginx/nginx.conf
文件中的 uwsgi 缓冲区值
server {
uwsgi_buffer_size 8k;
uwsgi_buffers 4 8k;
uwsgi_busy_buffers_size 16k;
# ... #
和 /etc/slashdb/slashdb.ini
文件,在 [uwsgi]
部分的末尾添加 buffer-size = 32768
。 uwsgi 部分应该如下所示:
# uWSGI config for service scriptm starts uWSGI as a daemon
[uwsgi]
socket = 127.0.0.1:8001
virtualenv = /opt/slashdb
daemonize = /var/log/slashdb/uwsgi.log
log-maxsize = 20971520
master = true
enable-threads = true
single-interpreter = true
lazy-apps = true
processes = 1
threads = 2
paste = config:%p
paste-logger = %p
buffer-size = 32768
然后重启服务:
sudo service slashdb stop
sudo service slashdb start
sudo service nginx restart
BTW SlashDB 目前不反映 BLOB 类型,但如果您将 testData
列类型更改为 text
,那么您将能够在 Data Discovery 中使用 POST 方法来接缝更适合您的用例。
使用 curl 它将是
curl -v 'http://slashdb.reshareu/db/testing/test_result.json' \
-X POST \
-H 'apikey: your-api-key-here' \
-H 'content-type: application/json' \
--data '{
"test_instance_test_station_id": "BO-01",
"test_instance_contact_address_id": 99,
"test_instance_unit_sn": "991807000003",
"testStep": "test2",
"externalDataLink": "bye2",
"test_instance_id": 116,
"testData": "Very long yata, yata, yata..."
}'