Skip to content

Commit 82926fe

Browse files
authored
Merge pull request #3992 from manticoresoftware/http_dist_error
fixed missed error message for HTTP update and delete queries into distributed table from the agents
2 parents fed8cd1 + 1437455 commit 82926fe

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

src/searchdhttp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ void HttpHandler_c::ReportError ( const char * sError, HttpErrorType_e eType, EH
10951095
const char * sErrorType = GetErrorTypeName ( eType );
10961096
int iStatus = HttpGetStatusCodes ( eStatus );
10971097
CSphString sReply = ( sErrorType ? JsonEncodeResultError ( m_sError, sErrorType, iStatus, sIndex ) : JsonEncodeResultError ( m_sError, iStatus ) );
1098-
HttpBuildReplyHead ( GetResult(), eStatus, sReply.cstr(), sReply.Length(), false );
1098+
BuildReply ( sReply, eStatus );
10991099
}
11001100

11011101
void HttpHandler_c::BuildReply ( const CSphString & sResult, EHTTP_STATUS eStatus )

src/sphinxjsonquery.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,8 +3006,9 @@ bool sphGetResultStats ( const char * szResult, int & iAffected, int & iWarnings
30063006
JsonObj_c tReason = tReplyError.GetItem ( "reason" );
30073007
if ( tReason && tReason.IsStr() )
30083008
sError = tReason.StrVal();
3009-
}
3010-
if ( sError.IsEmpty() )
3009+
} else if ( tReplyError.IsStr() )
3010+
sError = tReplyError.StrVal();
3011+
else if ( sError.IsEmpty() )
30113012
sError = tReplyError.AsString();
30123013

30133014
iAffected = 0;

test/clt-tests/bugs/3481-http-update-distributed-table-wrong-cluster-crash.rec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ curl -s -X POST http://localhost:9312/update -d '{"cluster": "unknown_cluster",
3838
––– input –––
3939
sleep 2; cat /var/log/manticore/searchd.log | grep 'response data' | head -n 1 | awk -F 'response data: ' '{print $2}'
4040
––– output –––
41-
{"version":3,"type":"json response","message":{"error":{"type":"action_request_validation_exception","reason":"table t: table 't' is not in any cluster, use just 't'","table":"t"},"status":409},"meta":null,"error_code":0}
41+
{"version":3,"type":"json response","message":{"error":"table t: table 't' is not in any cluster, use just 't'"},"meta":null,"error_code":0}

test/test_344/model.bin

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
a:1:{i:0;a:10:{i:0;a:6:{s:13:"http_endpoint";s:9:"json/bulk";s:11:"http_method";s:4:"POST";s:12:"http_request";s:473:"{ "insert" : { "table" : "test_rt", "id" : 1, "doc": { "tag" : 1, "content" : "doc one" } } }
1+
a:1:{i:0;a:12:{i:0;a:6:{s:13:"http_endpoint";s:9:"json/bulk";s:11:"http_method";s:4:"POST";s:12:"http_request";s:473:"{ "insert" : { "table" : "test_rt", "id" : 1, "doc": { "tag" : 1, "content" : "doc one" } } }
22
{ "insert" : { "table" : "test_rt", "id" : 2, "doc": { "tag" : 2, "content" : "doc two" } } }
33
{ "insert" : { "table" : "test_rt", "id" : 3, "doc": { "tag" : 3, "content" : "doc three" } } }
44
{ "insert" : { "table" : "test_rt", "id" : 4, "doc": { "tag" : 4, "content" : "doc four" } } }
@@ -21,4 +21,13 @@ a:1:{i:0;a:10:{i:0;a:6:{s:13:"http_endpoint";s:9:"json/bulk";s:11:"http_method";
2121
"id":1
2222
}";s:4:"rows";s:55:"{"table":"dist","id":1,"found":true,"result":"deleted"}";s:9:"http_code";i:200;s:4:"http";i:1;}i:7;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:51:"{ "table": "dist", "query": { "match_all": {} } } }";s:4:"rows";s:325:"{"timed_out":false,"hits":{"total":4,"total_relation":"eq","hits":[{"_id":2,"_score":1,"_source":{"content":"doc two","tag":200}},{"_id":3,"_score":1,"_source":{"content":"doc three","tag":200}},{"_id":4,"_score":1,"_source":{"content":"doc four","tag":200}},{"_id":5,"_score":1,"_source":{"content":"doc five","tag":200}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:8;a:6:{s:13:"http_endpoint";s:9:"json/bulk";s:11:"http_method";s:4:"POST";s:12:"http_request";s:137:"{ "delete" : { "table" : "dist", "id" : 2 } }
2323
{ "delete" : { "table" : "dist", "id" : 3 } }
24-
{ "delete" : { "table" : "dist", "id" : 4 } }";s:4:"rows";s:273:"{"items":[{"delete":{"table":"dist","id":2,"found":true,"result":"deleted"}},{"delete":{"table":"dist","id":3,"found":true,"result":"deleted"}},{"delete":{"table":"dist","id":4,"found":true,"result":"deleted"}}],"current_line":3,"skipped_lines":0,"errors":false,"error":""}";s:9:"http_code";i:200;s:4:"http";i:1;}i:9;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:51:"{ "table": "dist", "query": { "match_all": {} } } }";s:4:"rows";s:133:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":5,"_score":1,"_source":{"content":"doc five","tag":200}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}}}
24+
{ "delete" : { "table" : "dist", "id" : 4 } }";s:4:"rows";s:273:"{"items":[{"delete":{"table":"dist","id":2,"found":true,"result":"deleted"}},{"delete":{"table":"dist","id":3,"found":true,"result":"deleted"}},{"delete":{"table":"dist","id":4,"found":true,"result":"deleted"}}],"current_line":3,"skipped_lines":0,"errors":false,"error":""}";s:9:"http_code";i:200;s:4:"http";i:1;}i:9;a:6:{s:13:"http_endpoint";s:11:"json/search";s:11:"http_method";s:4:"POST";s:12:"http_request";s:51:"{ "table": "dist", "query": { "match_all": {} } } }";s:4:"rows";s:133:"{"timed_out":false,"hits":{"total":1,"total_relation":"eq","hits":[{"_id":5,"_score":1,"_source":{"content":"doc five","tag":200}}]}}";s:9:"http_code";i:200;s:4:"http";i:1;}i:10;a:6:{s:13:"http_endpoint";s:11:"json/delete";s:11:"http_method";s:4:"POST";s:12:"http_request";s:30:"{
25+
"table":"dist_t",
26+
"id":1
27+
}";s:4:"rows";s:173:"{"error":{"type":"action_request_validation_exception","reason":"table test_t: table test_t: table not available, or does not support DELETE","table":"dist_t"},"status":409}";s:9:"http_code";i:409;s:4:"http";i:1;}i:11;a:6:{s:13:"http_endpoint";s:11:"json/update";s:11:"http_method";s:4:"POST";s:12:"http_request";s:59:"{
28+
"table":"dist",
29+
"doc":
30+
{
31+
"missed_attr" : 200
32+
}
33+
}";s:4:"rows";s:159:"{"error":{"type":"action_request_validation_exception","reason":"table test_rt: table test_rt: attribute 'missed_attr' not found","table":"dist"},"status":409}";s:9:"http_code";i:409;s:4:"http";i:1;}}}

test/test_344/test.xml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,19 @@ index dist
2929
type = distributed
3030
agent = <my_address/>:test_rt
3131
}
32+
33+
index test_t
34+
{
35+
type = template
36+
min_word_len = 2
37+
}
38+
39+
index dist_t
40+
{
41+
type = distributed
42+
agent = <my_address/>:test_t
43+
}
44+
3245
</config>
3346

3447
<httpqueries>
@@ -86,6 +99,25 @@ index dist
8699

87100
<query endpoint="json/search">{ "table": "dist", "query": { "match_all": {} } } }</query>
88101

102+
<!-- error from the agent for HTTP update and delete -->
103+
<query endpoint="json/delete">
104+
{
105+
"table":"dist_t",
106+
"id":1
107+
}
108+
</query>
109+
110+
<query endpoint="json/update">
111+
{
112+
"table":"dist",
113+
"doc":
114+
{
115+
"missed_attr" : 200
116+
}
117+
}
118+
</query>
119+
120+
89121
</httpqueries>
90122

91123
</test>

0 commit comments

Comments
 (0)