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

x/tools/cmd/godoc: HTTP server never rechecks index if initial index is invalid #26027

Open
eklitzke opened this Issue Jun 23, 2018 · 2 comments

Comments

Projects
None yet
5 participants
@eklitzke

eklitzke commented Jun 23, 2018

What version of Go are you using (go version)?

go version go1.10.3 linux/amd64

Does this issue reproduce with the latest release?

Yes, and on master.

What did you do?

In a terminal:

$ cp /dev/null ./index
$ godoc -http=:6060 -index -index_files=./index
2018/06/23 13:21:03 error reading index from file ./index: EOF

Requests made to the godoc HTTP server will fail. The error message is printed by Corpus.RunIndexer(), and with the combination of flags listed above the index will never be re-checked.

In another terminal:

$ godoc -write_index -index_files=./index

After this process completes there is a valid index file for the HTTP server. However, index search requests will still fail, as the HTTP server will not try to re-initialize the index. There is no mechanism to ask the HTTP server to reload the index other than restarting the godoc process.

What did you expect to see?

I expect the index to service queries once the index file becomes valid.

My proposed semantics: if -index and -index_files are both specified but the index is in an uninitialized state, search queries should try to re-initialize the index. This would cause the index to be checked on every query until the index can be successfully loaded.

@gopherbot gopherbot added this to the Unreleased milestone Jun 23, 2018

@meirf

This comment has been minimized.

Member

meirf commented Jun 23, 2018

@agnivade

This comment has been minimized.

Member

agnivade commented Jun 24, 2018

Interesting scenario. I am curious to know whether you actually encountered this in a real situation (and if so, how), or you would like to see this feature.

The current way seems like the cleanest option to me. I think we should just fail to start if an invalid index file is provided. Starting a server with corrupted state does not seem very right.

Maybe we can expose a handler url to ask the server to re-initialize the index, if a user has updated the index file (but only after the server has initialized with a correct index). Checking it for every query seems unnecessary. A query should just return results from the index, or an error if something went wrong.

Anyway, I don't see a real perf benefit because the server has to re-initialize the index all over again. Just that you don't have to restart the godoc server.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment