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

Occasional Failed to derive xcontent in bulk index #286

Open
bejayoharen opened this issue Nov 18, 2016 · 0 comments
Open

Occasional Failed to derive xcontent in bulk index #286

bejayoharen opened this issue Nov 18, 2016 · 0 comments

Comments

@bejayoharen
Copy link

I am bulk indexing content, and decided to overwrite the sender function so that:

  1. I could retry failures
  2. I could get a report of errors

I'm indexing a small amount of content (My service reports about 500 writes/day) and every so often (maybe every two days or so), I get this error message:

{"error":{"root_cause":[{"type":"parse_exception","reason":"Failed to derive xcontent"}],"type":"parse_exception","reason":"Failed to derive xcontent"},"status":400}

From what I understand of elastic search, this means the data is badly formatted, so I printed out the buffer that's being sent to the bulk method and it appears to contain a single colon character.

I'm scratching my head to try to figure out what input I could have given the library to make it try to send invalid data to elastic search. I don't think I've done anything unusual, just using the standard BulkIndex functions that elastigo provides.

I haven't seen this in my test environment, but I'll do additional tests in case I missed it.

I'm sorry I can't provide much more info that this at this time, but I thought I would report it in case you have suggests for further debugging I can do or in case anyone else is seeing this. I realize this bug report might be useless at this point :(

Here is my sender method:

bulkIndexer.Sender = func(buf *bytes.Buffer) error {
		var respJson []byte
		var err error = nil
		tries := 15
		for try := 0; try < tries; try++ {
			// sleeps up to about 3 minutes:
			time.Sleep(time.Duration(try*try) * time.Second)
			// do it:
			respJson, err = c.DoCommand("POST", "/_bulk", nil, buf)
			if err == nil {
				break
			}
			if try < tries-1 {
				WARN.Println("Error in bulk indexing:", err, "Will retry.")
			}
		}
		if err != nil {
			message := "There was an error in bulk indexing after " + strconv.Itoa(tries) + " tries\n"
			message += "Error: " + string(respJson) + "\n"
			message += "Bulk Message: " + buf.String()
			ERROR.Println(message)
			EmailAdminErrorRateLimited("Error Indexing search", message, err, "searchtasks")
		}
		return err
	}
	bulkIndexer.Start()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant