Repository navigation
[Server] Store credentials as text - #2169
Conversation
|
/review |
a73e429 to
6700529
Compare
|
/review |
6700529 to
45b590a
Compare
|
/review |
45b590a to
345ab6a
Compare
|
/review |
345ab6a to
0a4c042
Compare
|
/review |
0a4c042 to
847cc94
Compare
|
/review |
…s fail (#2176) ## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2176/files) to review incremental changes. - [stack/storage_errors](#2176) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2176/files)] --------- **Description of changes** The server's own AWS SDK calls (S3, STS) put the storage's error text, which can name its endpoint, into error responses. They now return a general error. - `StorageExceptions`: an `SdkException` in the cause chain becomes `INTERNAL` "Failed to access storage.", in `BaseExceptionHandler` and `TransactionManager` - the walk stops at a `BaseException`, which already says what callers get - the cause is kept, so the handler logs it once with the response - A failed `AssumeRole` returns `INTERNAL` "Failed to vend temporary storage credentials.", with the STS exception as its cause - A storage cleanup that fails this way records its error code and its cause's class, such as `INTERNAL caused by StsException`, still without any message text Behavior change: the status and error code of these failures are unchanged (`INTERNAL`, HTTP 500), but the message no longer includes the storage or STS text. A storage failure anywhere in the cause chain now takes precedence over the `INVALID_ARGUMENT`, `UNAUTHENTICATED` and database error-code mappings, so an `IllegalArgumentException` that wraps one is reported as `INTERNAL`. `BaseException`s the server builds itself, such as the region errors in `FileOperationsImpl`, are unaffected. Azure and GCS failures are not covered. Note: independent of the S3-compatible storage stack (#2170 to #2175, then #2169). Once this merges, #2172 adds a test that relies on this error handling. Tests: handler tests for the UC, Iceberg and Delta APIs; `TransactionManagerTest`; `CloudCredentialVendorTest`. **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. --------- Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
5ca35b5 to
b808eab
Compare
|
/review |
|
/review |
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2173/files) to review incremental changes. - [stack/s3compat_spec](#2170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)] [MERGED] - [stack/s3compat_credentials](#2171) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)] [MERGED] - [stack/s3compat_vending](#2172) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)] [MERGED] - [**stack/s3compat_hadoop_cli**](#2173) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)] ← _this PR_ - [stack/s3compat_test_storage](#2174) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files/7d5ddf7e9720b6f2cec3fc71ccb53d54d8673ae7..e7e2bc04280b0b124a3a9a3a2900c0e90f0b46ff)] - [stack/s3compat_helm_key](#2175) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files/e7e2bc04280b0b124a3a9a3a2900c0e90f0b46ff..4443034338bd1eca465258461ca6426763358b6a)] - [stack/s3compat_credentials_text](#2169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/4443034338bd1eca465258461ca6426763358b6a..ed888a1e8e6bd11d226dbc2c354006a9e26e3b8f)] --------- Part of a stack adding experimental S3-compatible storage (MinIO, Ceph, SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR builds on the one before it; the files changed since the previous PR are under the link above. **Description of changes** Engines use the endpoint and region vended for S3-compatible storage. - `S3CredPropsBuilder` sets `fs.s3a.bucket.<bucket>.endpoint`, `.endpoint.region` and `.path.style.access` per vended credential, and the vended keys with a provider that reads them (`SimpleAWSCredentialsProvider` or `TemporaryAWSCredentialsProvider`), or the vended provider with renewal, since a bucket option in the engine's configuration overrides a global one - the bucket is read from the prefix as text, so underscores and characters invalid in a URI work - two credentials that put one bucket on different storage are rejected - `FileSystemCredId`: for a bucket with an S3 endpoint, the credential-scoped file system cache key includes a hash of the bucket and every S3A option for it, at bucket scope and global (the endpoint and region, transport and signing options, and the engine's own S3A credentials, credential stores and assumed role), except the per-load `fs.s3a.init.*` credentials and other buckets' options, so one bucket name on two storages, or under two engine S3A configurations, never shares a file system ; for any S3 path without vended keys (the table load records whether the vended keys sign the bucket's requests, as `fs.unitycatalog.vended.s3.keys.<bucket>`: not for a keyless vend, several AWS S3 credentials without renewal, or an engine whose own bucket provider, bucket keys without renewal, or global provider without renewal signs instead, or, without renewal, any configured Hadoop credential store, which S3A reads before the vended keys, or S3A delegation tokens, whose token signs; a value only from Hadoop's own defaults, such as S3A's default provider list, does not count as the engine's), or a bucket the table load did not route, the key includes the S3A settings hash and the current Hadoop user, told apart as Hadoop's own file system cache does (so two users of one name with different credentials do not share), since the engine then signs with its own keys, which may differ per user however the engine resolves them; AWS S3 paths with vended keys keep their key, unless the engine sets a global `fs.s3a.endpoint` or `fs.s3a.endpoint.region`, or the bucket's own `endpoint.region` - Credentials without keys leave the engine's own S3A credentials in use, without the vended provider - S3-compatible keys and the vended provider are set only at the scope of their buckets; a table whose credentials are all S3-compatible gets no global provider or keys, so another bucket the file system opens does not get them. The storage hash matches the URI scheme case-insensitively. - several credentials with keys for S3-compatible storage need credential renewal and credential-scoped file systems, or the table load refuses them - a table's credentials are assumed to be all with keys or all without; a mix is rejected, with a `TODO` to process each credential on its own - Renewal only for credentials that can expire; several credentials always take the vended provider, which picks the one covering each path - the table load records each bucket's vended endpoint and region (`fs.unitycatalog.vended.s3.*`, empty for AWS S3), and a renewal for other storage, including a switch between AWS S3 and S3-compatible storage, fails with a message that names both storages and asks to load the table again, since the open file system keeps its endpoint; a renewal that changes only the region, as after the server first used a fallback, is taken; the initial credential's region travels as `fs.s3a.init.s3.region` - the check compares a renewal with the record of the bucket the file system serves (from its prefix, or the table's only recorded bucket), and refuses a renewal for another bucket, as for a table recreated elsewhere; it runs once per credential rather than per request; a bucket without a record, or a renewal with no storage path to check, takes only AWS S3 renewals; the provider credential cache keys on the recorded storage, so a table loaded for new storage does not get a credential cached for the old one; `fs.s3a.init.s3.endpoint` and `.region` are always written, empty when unset - `AwsVendedTokenProvider` returns `AwsBasicCredentials` for a key pair without a session token - a renewal that gets only the endpoint, for example after the server's vending mode changed, fails with a message to load the table again - A vended key pair without a session token sets `fs.s3a.session.token` to empty, so a configured token is not paired with it - When every credential is for S3-compatible storage, no global vended provider is set, and one the engine's own configuration lists is dropped from its list, keeping its other providers (an empty list is S3A's default chain), so the keys reach only their buckets - `DeltaKernelUtils` (CLI) sets the vended endpoint, region and, for S3-compatible storage, the keys at the table's bucket scope only (global keys for AWS S3); only a response with just the endpoint leaves the keys to the environment, and a session token that is set must not be empty; the CLI turns off Hadoop's S3A file system cache, whose key ignores the endpoint and keys - `AwsCredential` treats an empty endpoint, region or session token as absent, as the renewal path already did - The same-bucket check counts AWS S3 paths too, so a bucket name on both AWS and S3-compatible storage is rejected rather than sent to one of them - A session token stays required without an S3 endpoint: the provider reads the endpoint back from `fs.s3a.init.s3.endpoint`, and otherwise fetches from Unity Catalog as before; an empty `fs.s3a.init.session.token` is no token - Responses without storage credentials, or without a cloud config, still fail as before Known: - An open file system does not follow a change of a credential's storage: its renewal fails instead, and the next table load gets the new storage. - Without a bucket-scoped endpoint the cache key has no storage hash, so engine configurations that differ only in their own global `fs.s3a.endpoint` or path style share a credential-scoped file system, as before this change. - A credential store entry (`hadoop.security.credential.provider.path`) for a bucket's `access.key` or `secret.key` takes precedence over fixed vended keys, as for the global keys on the AWS path. The `--s3_*` CLI options are documented with the user docs, later in the series. Compatibility: AWS, Azure and GCS behavior is unchanged. Tests: Hadoop connector and CLI suites. **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
ed888a1 to
9bc3fef
Compare
|
/review |
9bc3fef to
5f03fa8
Compare
|
/review |
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2174/files) to review incremental changes. - [stack/s3compat_spec](#2170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)] [MERGED] - [stack/s3compat_credentials](#2171) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)] [MERGED] - [stack/s3compat_vending](#2172) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)] [MERGED] - [stack/s3compat_hadoop_cli](#2173) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)] [MERGED] - [**stack/s3compat_test_storage**](#2174) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)] ← _this PR_ - [stack/s3compat_helm_key](#2175) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files/e4edf9f3cb2f7685ca8d668575fba4965e074cc0..e6386ee8b80766ae9be833dc4eacea0b024af8fd)] - [stack/s3compat_credentials_text](#2169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/e6386ee8b80766ae9be833dc4eacea0b024af8fd..5f03fa8c88f5ccda9608158e0585bdcac6a8c08e)] --------- Part of a stack adding experimental S3-compatible storage (MinIO, Ceph, SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR builds on the one before it; the files changed since the previous PR are under the link above. **Description of changes** Runs the tests on real S3-compatible storage in Docker. Tests, sbt aliases and an `AGENTS.md` line only; the spec and connector changes in the diff against `main` come from #2170 to #2173. - `server/src/test/.../teststorage`: a harness selected by `UC_TEST_STORAGE`, like `UC_TEST_DATABASE` - MinIO, SeaweedFS and RustFS with STS - Ceph and Garage without STS, in both `static-key-vending` modes - sbt aliases: `testMinIO`, `testSeaweedFS`, `testRustFS`, `testCeph`, `testCephStaticKey`, `testGarage`, `testGarageStaticKey` - `S3CompatibleCredentialScopeTest`: on real storage, a session vended for a table, a path or a volume reaches only its directory (a sibling, a prefix twin and the bucket root are denied, for reads, writes, deletes and lists), a write credential deletes only there, and a read credential cannot write or delete - `S3CompatibleCredentialVendingTest`: every vending endpoint, per credential and mode - The storage suites and `BaseSparkIntegrationTest` turn on `server.s3-compatible-storage.enabled` (off by default in `BaseServerTest`) - `BaseSparkIntegrationTest` runs the Spark suites on the selected storage, resolved on use (`s3Storage()`) so a failed start reports its cause in each suite; with an endpoint-only vend the engine brings only the keys, and the routing comes from the vend, except for the bucket that gets none - `AGENTS.md` mentions the aliases - Each storage stops what it started when its start or setup fails, and `TestStorages.selected` remembers the failure, so later tests fail at once - `McRunner`, shared by MinIO and RustFS, retries a dropped or hung `mc` admin call (each attempt runs under `timeout` with at most 20 seconds of the time left) for up to a minute; a retried change already in effect counts as done; each harness S3 request is capped at 20 seconds, so the setup loops reach their deadline; Ceph and Garage setup commands run with a deadline too (`ContainerExec`), and a failed Ceph install points at `CEPH_VERSION`, since Ubuntu's index keeps only the newest build Not in CI: the aliases are run manually, and need Docker. Tests: Spark emulated; MinIO: scope, vending and Spark suites; Garage: vending and Spark suites (the scope suite is skipped, since Garage has no STS to scope sessions). **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [ ] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
30ecaef to
8184858
Compare
timothyw553
left a comment
There was a problem hiding this comment.
left a few comments -- mainly around keeping @Lob so starting before v4 doesn't break existing postgresql credentials, and fixing the UC_TEST_MIGRATION_CHECKS=true failures.
| @Lob | ||
| @Column(name = "credential", nullable = false) | ||
| // Text, not a large object; the length makes it mediumtext rather than tinytext on MySQL. | ||
| @Column(name = "credential", nullable = false, length = 16777215) |
There was a problem hiding this comment.
if the new server starts on postgresql before v4 runs, hibernate's hbm2ddl.auto=update converts oid to text holding the raw oid number (e.g. "16871"), making existing credentials unreadable and causing a later v4 run to fail on lo_get(text). why not keep @Lob with length = 16777215 like ColumnInfoDAO.typeText so mysql gets mediumtext while 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?
- // Text, not a large object; the length makes it mediumtext rather than tinytext on MySQL.
+ @Lob
@Column(name = "credential", nullable = false, length = 16777215)There was a problem hiding this comment.
Thanks, I reproduced it on PostgreSQL 18. Starting the server before V4 does turn the column into text holding the large object's number. V4 then passes rather than failing on lo_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-schema before 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.md now 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 @Lob would keep credentials as large objects on PostgreSQL, which is what the step removes.
| @@ -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'); | |||
There was a problem hiding this comment.
running MigrationStepRulesTest with UC_TEST_MIGRATION_CHECKS=true fails on all three databases right now. typeChangesWiden rejects both oid to text and mysql's tinytext to mediumtext, and eachStepIsOneAllowedStatement also rejects the USING clause here. if we drop the postgresql conversion, could we add tinytext to MigrationStepRulesTest.WIDER for mysql (or add a narrow tested rule if the conversion stays) and rerun UC_TEST_MIGRATION_CHECKS=true across h2, postgresql, and mysql?
DatabaseKind.MYSQL,
Map.of(
+ "tinytext", Set.of("text", "mediumtext", "longtext"),
"varchar", Set.of("text", "mediumtext", "longtext"),| a large object, read as UTF-8, so a database whose encoding cannot hold a stored credential's characters | ||
| fails the step. It reads every credential's large object, so run `--upgrade-schema` as a role that can | ||
| read them, such as their owner; if one cannot be read or is missing, the step fails and changes nothing; | ||
| restore that large object, or delete and recreate its credential, then run it again. On PostgreSQL and |
There was a problem hiding this comment.
if we keep the postgresql conversion, how would an operator delete and recreate a credential while the server has to stay stopped, without leaving uc_external_locations pointing to a missing credential_id? also, "changes nothing" only holds for v4 itself since earlier pending steps may already have committed, and --upgrade-schema connects as hibernate.connection.username. could we mention that configured role and spell out the offline recovery steps (preferring restoring from backup, or how to relink dependent external locations if deleting the row)?
| fails the step. It reads every credential's large object, so run `--upgrade-schema` as a role that can | ||
| read them, such as their owner; if one cannot be read or is missing, the step fails and changes nothing; | ||
| restore that large object, or delete and recreate its credential, then run it again. On PostgreSQL and | ||
| MySQL, run `--upgrade-schema`, which applies schema step V4, before starting a server of this release: |
There was a problem hiding this comment.
nit: to my understanding, hibernate.hbm2ddl.auto=update is still on at startup and already widens mysql's tinytext column to mediumtext without losing data. should we describe --upgrade-schema as recommended rather than required on mysql until startup actually enforces schema migration first (here and on line 7)?
|
/review |
## 🥞 Stacked PR Use this [link](https://github.com/unitycatalog/unitycatalog/pull/2175/files) to review incremental changes. - [stack/s3compat_spec](#2170) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2170/files)] [MERGED] - [stack/s3compat_credentials](#2171) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2171/files)] [MERGED] - [stack/s3compat_vending](#2172) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2172/files)] [MERGED] - [stack/s3compat_hadoop_cli](#2173) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2173/files)] [MERGED] - [stack/s3compat_test_storage](#2174) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2174/files)] [MERGED] - [**stack/s3compat_helm_key**](#2175) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2175/files)] ← _this PR_ - [stack/s3compat_credentials_text](#2169) [[Files changed](https://github.com/unitycatalog/unitycatalog/pull/2169/files/072e1addbbc64a6b3169931e97debeef205b2475..818485843e842b8d934adc3b6a115ae1747316de)] --------- Part of a stack adding experimental S3-compatible storage (MinIO, Ceph, SeaweedFS, RustFS, Garage): #2170 (merged) to #2175, then #2169. Each PR builds on the one before it; the files changed since the previous PR are under the link above. **Description of changes** The Helm chart passes the credential encryption key from a Kubernetes Secret. - `server.credentialEncryptionKeySecret`: the Secret named by `name` gives `UC_SERVER_CREDENTIAL_ENCRYPTION_KEY` from its `key` (default `encryptionKey`), through the existing secret env helper - only needed for the experimental `s3_compatible` credentials; unset by default - CI: - render checks: the variable renders once, from the Secret's name and key (default and custom), with every database, in the server container's one env list; a default render has none; no render writes the key to the generated properties - install: the PostgreSQL case creates a key Secret with `openssl rand -base64 32`, turns on `server.s3-compatible-storage.enabled`, and checks the server becomes ready and read the key; the file and MySQL cases keep the default install - Docs: - `docs/server/configuration.md`: the key's environment variable, that the chart passes it with any database, and when it is needed - chart README: a complete example (the Secret plus the flag), linked from the `server.config.override` and `server.credentialEncryptionKeySecret.name` docs - Regenerated `helm/README.md` Compatibility: additive and opt-in. **PR Checklist** - [x] A description of the changes is added to the description of this PR. - [ ] If there is a related issue, make sure it is linked to this PR. - [x] If you've fixed a bug or added code that should be tested, add tests! - [x] If you've added or modified a feature, documentation in `docs` is updated This pull request and its description were written by Isaac. Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
8184858 to
7753024
Compare
|
/review |
7753024 to
cd8f6a5
Compare
|
/review |
| case ALTER -> kind != DatabaseKind.MYSQL && (changesType(change) || dropsNotNull(change)); | ||
| case ALTER -> | ||
| kind != DatabaseKind.MYSQL | ||
| && (changesType(change) |
There was a problem hiding this comment.
to my understanding changesType(change) accepts any type change without USING. so a plain ALTER TABLE uc_tables ALTER COLUMN view_definition TYPE text gets through here before readsLargeObjectsAsText runs, and the new oid -> text entry in WIDER lets typeChangesWiden pass it too. that leaves the id strings in the column, the same damage as the hibernate startup case. should we send postgresql oid -> text only through readsLargeObjectsAsText, keep it out of changesType, and add the rejection case?
+ "POSTGRESQL|ALTER TABLE t ALTER COLUMN lo TYPE text|is not an allowed change",| On PostgreSQL, run `--upgrade-schema` before starting a server of this release. Starting one first | ||
| is not supported: Hibernate's update at startup turns the column into text holding each large | ||
| object's number, so the server cannot read the credentials, and step V4 then leaves the column as it | ||
| is. To recover, restore the backup. On MySQL a server start widens the column too, so running |
There was a problem hiding this comment.
in this state the large objects are still there, only the column holds their ids. so could we document repairing in place before falling back to the backup? something like UPDATE uc_credentials SET credential = convert_from(lo_get(credential::oid), 'UTF8') WHERE credential ~ '^[0-9]+$', run with servers stopped. also vacuumlo can't see ids stored in a text column, so if someone runs the cleanup on line 139 in this state it deletes the only copies. should we say not to run it until the credentials read back fine?
There was a problem hiding this comment.
Now that #2117 is merged, this state can't happen with this release: the server ignores hibernate.hbm2ddl.auto and refuses to start until --upgrade-schema has applied the steps. So no server of this release sees the column before step 4, and nothing can turn it into text holding large object ids. I removed the paragraph about starting before step 4, so there's no in-place repair to document. The vacuumlo note then only applies after step 4 has run, when the column no longer references the large objects.
timothyw553
left a comment
There was a problem hiding this comment.
sorry actually this may need changes for my comments
|
/review |
timothyw553
left a comment
There was a problem hiding this comment.
overall looks good, left one comment on quoted identifiers in MigrationStepRulesTest and a few on the upgrade docs and test coverage.
| if (kind != DatabaseKind.POSTGRESQL || !columnSpecs(change).isEmpty()) { | ||
| return false; | ||
| } | ||
| String table = alter.getTable().getName().toLowerCase(Locale.ROOT); |
There was a problem hiding this comment.
toLowerCase keeps quotes on identifiers like "credential", so a quoted name misses the oid lookup and slips past the guard. could we reuse unquoted() here and add rejection cases for quoted table/column names?
- String table = alter.getTable().getName().toLowerCase(Locale.ROOT);
- String name = change.getColDataTypeList().get(0).getColumnName().toLowerCase(Locale.ROOT);
+ String table = unquoted(alter.getTable().getName());
+ String name = unquoted(change.getColDataTypeList().get(0).getColumnName());| step. | ||
|
|
||
| Step V4 reads every credential's large object. `--upgrade-schema` connects as | ||
| `hibernate.connection.username`, so that user must be able to read them, such as their owner. If |
There was a problem hiding this comment.
doesn't the connection fall back to hibernate.connection.user when hibernate.connection.username isn't set? also, restoring a backup won't fix a permission error if the same user still lacks access -- could we split the missing-object case from granting SELECT (or running as owner)?
There was a problem hiding this comment.
Right, it does fall back to hibernate.connection.user (HibernateConfigurator), so the docs name both now. I also split the two cases: when the user can't read a large object, grant SELECT on it (GRANT SELECT ON LARGE OBJECT <oid> TO <user>) or run --upgrade-schema as the owner, then run it again. When the object is missing, restore it or the backup.
- `CredentialDAO.credential` drops `@Lob` and takes `length = 16777215` - Schema step `V4__credentials_credential_as_text`: MySQL `tinytext` to `mediumtext`, PostgreSQL large object to `text`, H2 unchanged - `docs/server/upgrades.md`: what step 4 does per database, that a PostgreSQL server must not start before it, its database user, recovery, `vacuumlo`, and going back - `MigrationStepRulesTest`: MySQL `tinytext` widens; on PostgreSQL only `TYPE text USING convert_from(lo_get(c), 'UTF8')` may change an `oid` column - Tests: stored credentials survive the step on all three databases; a long credential round-trips through the server Signed-off-by: Yi Li <[email protected]> Co-authored-by: Isaac <[email protected]>
|
/review |
🥞 Stacked PR
Use this link to review incremental changes.
Last of a stack adding experimental S3-compatible storage (MinIO, Ceph, SeaweedFS, RustFS, Garage): #2170 to #2175 are merged.
Description of changes
Stores credentials as text instead of PostgreSQL large objects, and widens the column on MySQL, where
tinytext(255 bytes) is too small for reals3_compatiblecredentials withassume_role. It makes the change #1928 plans foruc_credentials.credential, and is a placeholder until #1928 and its follow-up merge.Builds on #2117 (merged): the server starts only once the steps have run, so it never sees the column before step V4.
CredentialDAO.credentialdrops@Loband addslength = 16777215V4__credentials_credential_as_text, one statement per database:tinytexttomediumtextoid) totext, throughconvert_from(lo_get(credential), 'UTF8')docs/server/upgrades.md:hibernate.connection.username; a missing or unreadable one fails it, with how to recovervacuumlo, and a release from before the step cannot read the converted column on PostgreSQLTODO(#2169)onCredentialDAO.setS3CompatibleSchemaMigratorTest.upgradeKeepsStoredCredentialsAndFitsLongerOnes: a credential stored before the step (a large object on PostgreSQL, with two-, three- and four-byte characters) reads back as the same text, and one longer than 255 bytes fits, on all three databases; on PostgreSQL the old row is written through pgjdbc's large object pathSchemaMigratorTest.upgradeWithAMissingLargeObjectChangesNothing: on PostgreSQL, a credential whose large object is missing fails the step and leaves the column and the row as they wereMigrationStepRulesTest: MySQLtinytextwidens totext,mediumtextorlongtext; on PostgreSQL anoidcolumn may change only asTYPE text USING convert_from(lo_get(c), 'UTF8'), the one allowed change that rows can fail, with cases for it; a plain type change of anoidcolumn is refusedSchemaMigratorTest.refusesAStepThatDropsAConstraintTheDatabaseNoLongerHasByThatNamebrings the database to step 3 itself instead of to the newest step, so a later step no longer leaves a gap in its schema historyBaseCredentialCRUDTest.testLongS3CompatibleCredential: a credential over 1000 bytes, with non-ASCII text, round-trips through the server on every databaseCompatibility: no API change. Going back to an earlier release needs the database backup.
Tests:
SchemaMigratorTest,BaselineMatchesEntitiesTest,MigrationStepRulesTestand the credential and external location CRUD tests on H2, PostgreSQL 18 and MySQL 8 (MigrationStepRulesTestwithUC_TEST_MIGRATION_CHECKS=true); all pass.PR Checklist
docsis updatedThis pull request and its description were written by Isaac.