-
Notifications
You must be signed in to change notification settings - Fork 188
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
Add postgres support for JDBIHistory #1844
Conversation
* refactors HistoryJDBI into an interface, with an abstract base class for shared code (limit offset using standard SQL idiom) and concrete subclasses for Postgres and MySQL. * SingularityMappers can choose to use either f_user or user column - this is needed because Postgres considers user a reserved word. * Modify SingularityHistoryModule to handle the new bindings * JDBIHistoryManager - add debug logging at TRACE level.
…For now, this simply triggers the mysqljdbi
@ssalinas I deliberately split everything so.no migration or compatibility concerns would arise with mysql. They were 99.9999% compatible other than the user column and the offset limit syntax. But I thought this was cleaner in the end |
sqlBuilder.append(", requestId "); | ||
sqlBuilder.append(orderDirection.or(OrderDirection.DESC).name()); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only change in common code - flagging so you notice
@@ -1,19 +1,7 @@ | |||
package com.hubspot.singularity.data.history; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class now just an interface
return history.getTaskIdHistory(requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection, limitStart, limitCount); | ||
|
||
List<SingularityTaskIdHistory> taskIdHistoryList = history.getTaskIdHistory(requestId, deployId, runId, host, lastTaskStatus, startedBefore, startedAfter, updatedBefore, updatedAfter, orderDirection, limitStart, limitCount); | ||
if (LOG.isTraceEnabled()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added logging at trace level for the sql stuff. Seems a useful thing
@UseStringTemplate3StatementLocator | ||
public abstract class MySQLHistoryJDBI extends AbstractHistoryJDBI { | ||
|
||
@SqlUpdate("INSERT INTO requestHistory (requestId, request, createdAt, requestState, user, message) VALUES (:requestId, :request, :createdAt, :requestState, :user, :message)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty much the old jdbi history class minus the common code
…pecific postgres information as needed) * Cleaned up logging, helper methods
Hey @mikebell90 thanks for the PR! Was a busy week here at HubSpot, I will try and take a closer look at this early next week 👍 |
Cool! Thanks |
PR'ed a change into your branch @mikebell90 (mikebell90#3) . Will want to double check if there is the same issue for postgres in the |
@ssalinas Yeah that was dumb of me. I went on memory of MySQL that it accepted both in that order ;) |
Swap limit/offset
This has been pretty stable in our setup so far. I'd say let's 🚢 . We'll get this in our production branch and merged this week. Can try to cut a release hopefully this week as well |
Very cool! |
base class for shared code (limit offset using standard SQL idiom)
and concrete subclasses for Postgres and MySQL.