Repository navigation
[Server] Store credentials as text #2169
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| -- H2 stores credentials as clob, which already fits any credential. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Credentials can exceed tinytext's 255 bytes, so use mediumtext, the size of the other large text columns. | ||
| ALTER TABLE uc_credentials MODIFY COLUMN credential mediumtext NOT NULL; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| -- Credentials are stored as text instead of large objects. The conversion reads each large object; the | ||
| -- large objects themselves stay until vacuumlo removes them (see docs/server/upgrades.md). | ||
| ALTER TABLE uc_credentials ALTER COLUMN credential TYPE text USING convert_from(lo_get(credential), 'UTF8'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question (not a blocker): on PostgreSQL this step is not compatible with servers of the previous release. After it, they fail to read credentials, and a credential they create stores a large-object id (for example
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking. I think it is fine for servers of an older release to stop working once the database is upgraded to the newer schema: the upgrade guide already has you stop all servers before running the step, so I will keep it as it is rather than make this step online-compatible.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. running DatabaseKind.MYSQL,
Map.of(
+ "tinytext", Set.of("text", "mediumtext", "longtext"),
"varchar", Set.of("text", "mediumtext", "longtext"), |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
|
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - column uc_credentials.credential type=tinytext size=255 nullable=NO default=null | ||
| + column uc_credentials.credential type=mediumtext size=16777215 nullable=NO default=null |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| - column uc_credentials.credential type=oid size=10 nullable=NO default=null | ||
| + column uc_credentials.credential type=text size=2147483647 nullable=NO default=null |
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.
if the new server starts on postgresql before v4 runs, hibernate's
hbm2ddl.auto=updateconvertsoidtotextholding the raw oid number (e.g."16871"), making existing credentials unreadable and causing a later v4 run to fail onlo_get(text). why not keep@Lobwithlength = 16777215likeColumnInfoDAO.typeTextso mysql getsmediumtextwhile postgresql keeps its existing storage and a comment-only v4 step? if we keep the postgresql conversion instead, shouldn't server startup refuse an outdated schema before hibernate can alter it? could we also add a test that starts the server against a pre-v4 credential without migrating first?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.
Thanks, I reproduced it on PostgreSQL 18. Starting the server before V4 does turn the column into
textholding the large object's number. V4 then passes rather than failing onlo_get(text), and the column stays that way, so the credentials can't be read.We don't plan to support that order. On PostgreSQL this release has to run
--upgrade-schemabefore its first start, and #2117, which this PR merges after, makes the server refuse an outdated schema rather than let Hibernate alter it.docs/server/upgrades.mdnow says the earlier start isn't supported, describes what it does, and gives the backup as the recovery. So I left out a test for that start, since it's an unsupported path.I kept the conversion rather than
@Lob. Text is the storage that #1928 plans for these columns, and this PR stands in for that part of it. Keeping@Lobwould keep credentials as large objects on PostgreSQL, which is what the step removes.