Project

General

Profile

Feature #7960

Allow query logs to be collected in a H2 database

Added by Radu Apetrii 6 months ago. Updated 10 days ago.

Status:
Review
Priority:
Normal
Target version:
-
Start date:
Due date:
% Done:

100%

billable:
No
vendor_id:
GCD

Related issues

Related to Database - Feature #7416: Reiterate DatabaseStatistics and leverage to other database profling tools Test

History

#1 Updated by Radu Apetrii 6 months ago

Branch 7416b will be merged into trunk soon (good news). Those changes include the removal of DatabaseStatistics, mainly because it became deprecated and no longer usable since we don't make use of Hibernate anymore. However, with it, there was one interesting feature that was removed: the allowance of collecting query logs/data in a H2 database instead of a basic file.

The point of this task is to "revive" the feature of storing query logs into a H2 database and adapt its usage to our current code base.

#2 Updated by Alexandru Lungu 6 months ago

  • Related to Feature #7416: Reiterate DatabaseStatistics and leverage to other database profling tools added

#3 Updated by Alexandru Lungu 21 days ago

  • Assignee set to Ioana-Cristina Prioteasa

#4 Updated by Ioana-Cristina Prioteasa 10 days ago

I added the necessary modifications to support this feature, changes are now on branch 7960a, rev 15156.

#5 Updated by Ioana-Cristina Prioteasa 10 days ago

  • Status changed from New to WIP

#6 Updated by Ioana-Cristina Prioteasa 10 days ago

  • Status changed from WIP to Review
  • % Done changed from 0 to 100

#7 Updated by Alexandru Lungu 10 days ago

Review of 7960a:

  • For P2JLoggingDatabaseHelper construct:
    • Separate the connection from statement execution:
    • If the connection fails, no need to rollback connection or close the statement.
    • If the statement fails, the connection should be roll-backed.
  • time_stamp is not a valid name, use timeStamp. Change the javadoc as well.
  • In insetP2JQueryProgfiling, move the id null-check before return. An exception will omit that logging.
  • closeConnection: if you close a connection, you still need to make it null. Otherwise, you may end up using/closing the same connection all over again.
  • In P2JQueryLogger, avoid the import on java.sql.* (for Timestamp). Consider other package not that specific (as sql).
The changes are reasonable. Please do the testing necessary after assessing the review. Most important concern:
  • Make sure that this kind of logging is happening in servers that are not configured of doing such. Doing H2 logging for arbitrary configurations will end up in a big slow-down of production environments. Double-check your changes are not hit on an application that is not configured to do so.

#8 Updated by Ioana-Cristina Prioteasa 10 days ago

Changes are now on branch 7960a, rev 15157.
Regarding your concern: Make sure that this kind of logging is not happening in servers that are not configured of doing such.
Initially i mimicked the logic writing to file: if no database configuration was present in directory.xml i was using default values. Now you need to specify that database output is enabled as shown bellow:

  <node class="container" name="output-to-db">
    <node class="boolean" name="enabled">
      <node-attribute name="value" value="TRUE"/>
    </node>
    <node class="string" name="db-name">
      <node-attribute name="value" value="p2j_%db_%as"/>
    </node>
    <node class="string" name="db-user">
      <node-attribute name="value" value="user"/>
    </node>
    <node class="string" name="db-pass">
      <node-attribute name="value" value="pass"/>
    </node>
  </node>

If /output-to-db/enabled is not set to true, the logging will only happen in files. The rest of the attributes are not mandatory, if not present we use default values.

Also available in: Atom PDF