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

SQL: jdbc debugging enhancement #53880

Merged
merged 5 commits into from
Mar 24, 2020
Merged

Conversation

astefan
Copy link
Contributor

@astefan astefan commented Mar 20, 2020

This change adds a buffered debug output option that will flush the output printer after each debug message when enabled (disabled by default). Also, upon connection time and debug classes initialization, an additional debug log message is generated that contains information about OS, JVM and default JVM timezone setting.

after each debug message when enabled (disabled by default)
* upon connection time and debug classes initialization, log in debug
output information about OS, JVM and default JVM timezone
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/SQL)

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments regarding initialization.

@@ -75,6 +75,23 @@ public void testDebugOut() throws Exception {
assertThat(ci.debugOut(), is("jdbc.out"));
}

public void testDebugBuffered() throws Exception {
JdbcConfiguration ci = ci("jdbc:es://a:1/?debug=true&debug.buffered=false");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think debug.flushAlways or debug.noBuffer is more meaningful. I also like the consistency of the options - by default they are false and need to be turn on through true.
That is the default (false) is to always buffer but true would yield an immediate flush.

@@ -17,9 +17,11 @@
private static final String HEADER = "%tF/%tT.%tL - ";

final PrintWriter print;
private boolean debugBuffered;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to keep the prefix debug as this is a DebugXXX class.

OUTPUT_MANAGED.put(managedPrinter, log);
}
return log;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method changes make it more complicated and hard to follow - there's this log ==null being repeated which begs the question, what happens it if it initialized?
I think the method is good as it is - it creates a logger or returns one that already exists. Either wrap this method in another one that calls logSystemInfo (rename the existing method into something like createLogger and then logger calls createLogger().logSystemInfo or wrap that at the consumer site - inside proxy.

However currently the systemInfo is being called per each Connection which I think is excessive - we want the system information to be once per log, at the beginning.
In which case, the system info should called when a new log is created, essentially after each new DebugLog.
To keep things incapsulated, instead of calling the constructor, one could call a method createLog which internally calls new DebugLog and right after calls logSystemInfo.
This way any other initialization that would need to occur, would happen in that method regardless of the actual method taking place and only once per logger.
It might make sense to call flush after logging the system info.

@matriv matriv self-requested a review March 21, 2020 23:10
@astefan astefan requested a review from costin March 23, 2020 16:26
@astefan
Copy link
Contributor Author

astefan commented Mar 23, 2020

@costin very valid points. Pushed an update.

Copy link
Member

@costin costin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@matriv matriv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, nice!

@astefan astefan merged commit b5db965 into elastic:master Mar 24, 2020
astefan added a commit to astefan/elasticsearch that referenced this pull request Mar 24, 2020
* add flush always output option that will flush the output printer
after each debug message when enabled (disabled by default)
* at debug output initializationtime, log debug output
information about OS, JVM and default JVM timezone

(cherry picked from commit b5db965)
astefan added a commit to astefan/elasticsearch that referenced this pull request Mar 24, 2020
* add flush always output option that will flush the output printer
after each debug message when enabled (disabled by default)
* at debug output initializationtime, log debug output
information about OS, JVM and default JVM timezone

(cherry picked from commit b5db965)
astefan added a commit that referenced this pull request Mar 24, 2020
* add flush always output option that will flush the output printer
after each debug message when enabled (disabled by default)
* at debug output initializationtime, log debug output
information about OS, JVM and default JVM timezone

(cherry picked from commit b5db965)
@astefan astefan deleted the jdbc_debug_enhancement branch March 24, 2020 13:44
astefan added a commit that referenced this pull request Mar 24, 2020
* add flush always output option that will flush the output printer
after each debug message when enabled (disabled by default)
* at debug output initializationtime, log debug output
information about OS, JVM and default JVM timezone

(cherry picked from commit b5db965)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants