oracle / opengrok

OpenGrok is a fast and usable source code search and cross reference engine, written in Java
http://oracle.github.io/opengrok/
Other
4.34k stars 745 forks source link

An error occurred while reading history Failed to get history #1884

Closed JustSong closed 6 years ago

JustSong commented 6 years ago

OpenGrok Version: opengrok-1.1-rc11 JDK: Oracle java version "1.8.0_144" OS: Ubuntu 12.04.5 LTS Tomcat: Tomcat8

The History Error occurred in all project. It showed the following message when I process index step: An error occurred while reading history: org.opensolaris.opengrok.history.HistoryException Failed to get history for: "" Exit code: 128

vladak commented 6 years ago

What kind of repository is being indexed ? If you bump the logging level in logging.properties then you should see what commands are being run. That will help you to replicate the same on command line.

JustSong commented 6 years ago

Sorry, How can I bump my logging level in loggin.properties?

vladak commented 6 years ago

OpenGrok ships with logging.properties configuration file. Usually it is sufficient to change the level at the bottom of the file so it looks like this:

org.opensolaris.opengrok.level = ALL
JustSong commented 6 years ago

I thinks it always be set the correct setting, but the error message didn't show more information. org.opensolaris.opengrok.level = ALL

Error Message example: 08:52:32 WARNING: An error occurred while reading history: org.opensolaris.opengrok.history.HistoryException: Failed to get history for: "/opengrok/project/gcc/source/libcore/support/src/test/java/tests/resources/illegalClasses.jar" Exit code: 128 at org.opensolaris.opengrok.history.GitHistoryParser.parse(GitHistoryParser.java:165) at org.opensolaris.opengrok.history.GitRepository.getHistory(GitRepository.java:523) at org.opensolaris.opengrok.history.GitRepository.getHistory(GitRepository.java:516) at org.opensolaris.opengrok.history.FileHistoryCache.get(FileHistoryCache.java:553) at org.opensolaris.opengrok.history.HistoryGuru.getHistory(HistoryGuru.java:242) at org.opensolaris.opengrok.history.HistoryGuru.getHistory(HistoryGuru.java:202) at org.opensolaris.opengrok.history.HistoryGuru.getHistoryReader(HistoryGuru.java:186) at org.opensolaris.opengrok.analysis.AnalyzerGuru.populateDocument(AnalyzerGuru.java:343) at org.opensolaris.opengrok.index.IndexDatabase.addFile(IndexDatabase.java:667) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:949) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.indexDown(IndexDatabase.java:902) at org.opensolaris.opengrok.index.IndexDatabase.update(IndexDatabase.java:429) at org.opensolaris.opengrok.index.IndexDatabase$2.run(IndexDatabase.java:188) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

JustSong commented 6 years ago

The Opengrok Website always show File Not Found , if I click the History button on any file.

default

vladak commented 6 years ago

The website errors are just manifestation of the problem happening in the indexer.

vladak commented 6 years ago

The WARNING line in the log is basically telling you that the git command failed for some reason. The key for understanding why is to get exactly the command that is being run. Luckily, the command is logged in full to the log so find the preceding line starting with Executing command ... in the log and try to run it exactly (under the same user, for instance) in the directory of the repository.

For example, in my case it says:

2017-11-22 13:55:54.253+0100 FINE t54 Executor.exec: Executing command [/usr/bin/git, log, --abbrev-commit, --abbrev=8, --name-only, --pretty=fuller, --date=iso8601-strict, f2cdc095..] in directory /var/opengrok/src/OpenGrok

so I will run /usr/bin/git log --abbrev-commit --abbrev=8 --name-only --pretty=fuller --date=iso8601-strict f2cdc095.. in the /var/opengrok/src/OpenGrok directory.

vladak commented 6 years ago

For example, if I break one of the options on purpose, I will get return code 128:

/var/opengrok/src/OpenGrok$ /usr/bin/git log --abbrev-commit --abbrev=8 --name-only --pretty=fuller --date=TOTALLY_INVALID_DATE_FORMAT
fatal: unknown date format TOTALLY_INVALID_DATE_FORMAT
/var/opengrok/src/OpenGrok$ echo $?
128
vladak commented 6 years ago

Another question is what version of Git are you running ?

vladak commented 6 years ago

Also, Executor (the class responsible for actually running external commands) logs the standard output of commands that exited with non-zero return code with WARNING level so you should be able to see the reason why the command failed right there in the indexer log.

JustSong commented 6 years ago

Git version: 1.7.9.5

Yes, I found out the detail error message about git command fail.

10:41:44 WARNING: Non-zero exit status 128 from command [/usr/bin/git, log, --abbrev-commit, --abbrev=8, --name-only, --pretty=fuller, --date=iso8601-strict] in directory /opengrok/project/qt/source: fatal: unknown date format iso8601-strict

JustSong commented 6 years ago

Hi vladak,

I updated the git version to newest and the history was shown. Thanks a lot for your help.

vladak commented 6 years ago

Sometimes it is worth reading tjose logs ;-)

naveen0256 commented 5 years ago

Hi, recently, my machine has been upgraded. I have my git as 2.16.2 version installed. Still I am getting the same error /usr/bin/git, log, --abbrev-commit, --abbrev=8, --name-only, --pretty=fuller, --date=iso8601-strict] in directory /opengrok/project/qt/source: fatal: unknown date format iso8601-strict. Do I need to update git to a newer version that that?

tulinkry commented 5 years ago

And is /usr/bin/git your git 2.16? Because I'd guess it's not. Try running '/usr/bin/git --version` in console.