mirror of
https://github.com/floci-io/floci.git
synced 2026-11-23 06:00:46 -05:00
c8de16ffc7ca989b62ceaeaee1cc201bf50d8ce6
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
ae75a653d6 |
feat(redshift-data): add async execution and statement status events (#5383)
* feat(redshift-data): add async execution and statement status events
* fix(redshift-data): address review findings on async Data API
- Mark a statement FAILED when its worker dies unexpectedly instead of leaving it active
- Let unexpected publisher errors propagate; the delivery pool logs them at error level
- Run CREATE/DROP INDEX CONCURRENTLY, REINDEX CONCURRENTLY, ALTER SYSTEM and tablespace DDL outside a transaction
- Drop WaitTimeSeconds from Scheduler targets so the shared dispatcher thread never blocks
- Share result rows and column metadata between snapshots; ListStatements no longer copies results
- Replace the global monitor with a ReentrantReadWriteLock for status writes and reset
* fix(redshift-data): reject CancelStatement on terminal statements
- Throw ValidationException ("Could not cancel a query that is already in <STATE> state.") instead of returning Status false, as AWS does
- Use WaitTimeSeconds instead of 30 s polling in the Serverless compatibility test and the Spectrum integration test
* fix(redshift-data): match AWS CancelStatement message and tidy test signature
- Append "with ID: <id>" to the terminal-state ValidationException message
- Drop the unused throws InterruptedException from workgroupLifecycleUsesAwsSdk
|
||
|
|
950b6fe774 |
feat(redshift): add relational queries for Redshift Spectrum (#5095)
* feat: add relational queries for Redshift Spectrum * fix(redshift): harden Spectrum relational query preparation Catch RuntimeException during preparation so the client gets an ErrorResponse instead of a dropped connection, skip preparation while the backend discards until Sync, defer schema binding until the transaction commits, make the catalog functions SECURITY DEFINER, and track COMMIT and ROLLBACK from the command tag. * fix(redshift): address review findings on transaction handling in Spectrum relational queries - Undo Glue tables created inside a rolled back transaction (Data API batch and wire proxy) - Keep bindings and Glue tables on ROLLBACK TO SAVEPOINT; only a closed transaction discards them - Report the real transaction status for locally handled simple queries instead of idle - Use a switch expression in BackendResponseCoordinator - Map host.docker.internal into the floci-duck container on Linux * fix(redshift): undo Glue tables across sessions and on rollback to savepoint - Scope staged Glue tables by the backend socket so the proxy rollback finds tables created by another session - Track SAVEPOINT, ROLLBACK TO and RELEASE so a Data API batch undoes only the tables created after the savepoint * fix(redshift): defer Glue undo on rollback to savepoint until the backend confirms and bundle bootstrap catalog in native image * fix(redshift): reject CREATE EXTERNAL TABLE inside a transaction like AWS AWS does not allow CREATE EXTERNAL TABLE inside a transaction block, and a Data API batch runs as one transaction. Return SQLSTATE 25001 instead of staging Glue tables and undoing them on rollback, which removes the savepoint tracking and cross-session undo code. Reuse ExternalTableMaterializer.quote. * fix(redshift): reject CREATE EXTERNAL TABLE in a transaction for legacy schemas too |
||
|
|
99a6b4050c |
feat(redshift-serverless): add running workgroups and Data API WorkgroupName support (#5012)
* feat(redshift-serverless): add running workgroups and Data API WorkgroupName support Redshift Serverless workgroups get full CRUD (Create/Get/List/Update/Delete), tagging by ARN, and the AWS::RedshiftServerless::Namespace and ::Workgroup CloudFormation types with dotted Fn::GetAtt keys taken from the registry schema. A namespace has at most one workgroup, and DeleteNamespace is refused while one is attached. Each workgroup runs a PostgreSQL container behind an authenticating proxy, sharing the managers and the proxy port pool with provisioned Redshift. Add GetCredentials, accept WorkgroupName (name or ARN) in the Redshift Data API, and push a changed namespace adminUserPassword down to the running backend. The runtime is re-attached when Floci restarts. Not covered: snapshots, usage limits, endpoint access, and COPY/UNLOAD/Spectrum on workgroups. * fix(redshift-serverless): stop the runtime when workgroup creation fails after it started If persisting the workgroup record failed after the container and proxy were already running, the runtime was left behind with no record. createWorkgroup now stops it (best effort) and releases the endpoint on the failure path. Fix the CloudFormation error for a NamespaceName change: suggesting a new WorkgroupName can never succeed because a namespace holds only one workgroup. * fix(redshift-serverless): reset omitted CloudFormation properties and order startup observers When UpdateStack drops a property from the template, the provisioner now sends its default (BaseCapacity, EnhancedVpcRouting, PubliclyAccessible, Port, TrackName, PricePerformanceTarget) instead of keeping the stored value, which matches CloudFormation semantics. MaxCapacity has no default and keeps its stored value. Give the workgroup StartupEvent observer a @Priority after RedshiftService so every persisted cluster has reserved its proxy port before workgroups restore theirs. Also remove an unused import and move DEFAULT_DATABASE to the top of RedshiftContainerManager. * fix(redshift-serverless): address review findings on password rotation and namespace updates - Roll the backend password back when a rotation cannot be completed or stored, and apply it last so validation failures never leave the backend ahead of the stored namespace. - Keep a workgroup endpoint reserved when its runtime cannot be stopped during clear(). - Reject an in-place DbName change in CloudFormation, since it is fixed at creation. - Reset an omitted KmsKeyId and DefaultIamRoleArn on CloudFormation updates. * fix(redshift-serverless): keep rollback failures from masking errors and drop stale GetAtt role - Do not reset the proxy password when the role restore fails, and attach restore failures to the original exception instead of replacing it. - Remove Namespace.DefaultIamRoleArn from the stack resource when an update no longer declares a default role. * docs: correct the Redshift Serverless operation count in the service matrix * fix(redshift-serverless): expose Workgroup.ConfigParameters through Fn::GetAtt * fix(redshift-serverless): parse ConfigParameters resolved from a GetAtt attribute * docs(redshift-serverless): list every unsupported operation group |
||
|
|
569f9f55e4 |
perf(build): replace quarkus-jdbc extensions with plain JDBC drivers (#3465)
* perf(build): replace quarkus-jdbc extensions with plain JDBC drivers The RDS Data API and Redshift Data API open connections with DriverManager. They never used Agroal, Narayana or the datasource layer that quarkus-jdbc-mysql and quarkus-jdbc-postgresql pull in. Depend on mysql-connector-j and postgresql directly and hand-supply the native image config the extensions provided. * perf(build): cut unused JDBC driver paths from the native image Substitute driver code that cannot be reached against the databases Floci provisions, mirroring what quarkus-jdbc-mysql did for JMX and going a step further for authentication and multi-host URLs. * perf(build): keep the MySQL cleanup thread disabled in JVM mode quarkus-jdbc-mysql set com.mysql.cj.disableAbandonedConnectionCleanup at startup in JVM mode as well as at native build time. The first commit carried only the native build argument and a surefire copy, so quarkus:dev and the JVM Docker image started Connector/J's abandoned connection cleanup thread on the first MySQL Data API call. In dev mode that thread is recreated with every restart and pins the old classloader. * fix(rdsdata): reject PostgreSQL result types the Data API does not support Aurora PostgreSQL answers a result set that holds a point, interval, money, box, circle, line, lseg, path or polygon column with UnsupportedResultException and the message "The result contains the unsupported data type POINT." Floci returned the driver's toString of the value instead. Check the column type names before reading the rows and raise the same error. json and jsonb stay supported, and a column cast to text still reads as a string, which is the workaround AWS documents. * perf(build): drop the PGobject reflection entries pgjdbc builds point, interval, money and the geometric types through reflection only when a result set holds such a column. The Data API now rejects those columns before reading a row, and json and jsonb values are plain PGobject instances the driver creates directly, so none of the ten entries can be reached. * chore(rdsdata): name the tolerated ClassNotFoundException in OpenTelemetryUnavailable * perf(build): keep PGInterval registered for the Redshift Data API Redshift tables can hold INTERVAL YEAR TO MONTH and INTERVAL DAY TO SECOND columns and the Redshift Data API returns them as strings. Floci serves that path from a PostgreSQL container through pgjdbc, which builds an interval value by reflection, so the entry stays. The Redshift Data compat test now reads two interval columns on the native image. * perf(build): keep the geometric reflection entries for the Redshift Data API Redshift refuses point, box, circle, lseg, path and polygon as column types but evaluates them in a select, and its Data API returns the values as strings, checked on a real ra3.large cluster. Floci serves that path through pgjdbc, which builds those values by reflection, so the six entries stay. line stays out because Redshift rejects it, and money never reaches PGmoney because pgjdbc reads it as a double. The Redshift Data compat test selects those expressions and expects the strings Redshift returned. JdbcDriverNativeSupportTest resolves every registered class name. * fix(redshiftdata): fail statements that produce line, json or jsonb like Redshift Redshift has none of these types. A select that names one fails with "ERROR: type "line" not yet implemented" or "ERROR: type "json" does not exist", checked on a real cluster. The PostgreSQL container behind Floci's Redshift evaluates them, so the Data API now checks the result column types and fails the statement with the same text. |
||
|
|
6b17ef2b1c |
feat(redshift): emulate GetClusterCredentials and GetClusterCredentialsWithIAM (#3273)
* feat(redshift): add RedshiftCredentialBroker for short-lived Db credentials * refactor(rds-proxy): widen PasswordValidator to a three-value AuthResult The wire-level password check the PostgreSQL/MySQL proxy handlers take now returns REJECT / PASSTHROUGH / MASTER_EQUIVALENT instead of a boolean, so a caller can tell the proxy to open the backend leg as the cluster master for a client it has vouched for. RdsAuthProxy keeps its own boolean master-password callback, renamed MasterPasswordCheck to free the PasswordValidator name, and adapts it at the handler boundary (non-master stays PASSTHROUGH). * feat(redshift): auth proxy accepts live GetClusterCredentials credentials passwordValidatorFor now returns AuthResult and consults RedshiftCredentialBroker: the master pair and any live minted credential resolve to MASTER_EQUIVALENT, a known broker user with a stale password is REJECTed, everyone else PASSTHROUGH. * feat(redshift): add default-credential-duration-seconds config * feat(redshift): implement GetClusterCredentials action Mints a short-lived DbUser/DbPassword pair via RedshiftCredentialBroker and returns it as Query-protocol XML. AutoCreate prefixes IAM: on the DbUser, DbGroups are echoed, DurationSeconds is validated to 900-3600 (default from the new config key), and an unknown ClusterIdentifier propagates ClusterNotFound. The two credential actions are registered in AwsQueryController.REDSHIFT_ACTIONS and the Query dispatch now forwards the Authorization header to the handler. * feat(redshift): implement GetClusterCredentialsWithIAM action Derives the DbUser from the caller's IAM identity resolved via the Authorization header: an IAM user maps to IAM:<name>, an assumed role to IAMR:<role>, and an unresolvable caller to the IAMR:floci fallback with a WARN so local and CI flows are not blocked. Any DbUser request parameter is ignored. * feat(redshift-data): resolve non-master DbUser via GetClusterCredentials resolveViaDbUser now accepts a DbUser that has a live credential in RedshiftCredentialBroker, connecting to the container as the cluster master (the minted DbUser is nominal). An unknown non-master DbUser still fails with ValidationException. * test(redshift): end-to-end GetClusterCredentials + Data API non-master DbUser Docker-gated: mints a credential for a non-master DbUser via GetClusterCredentials then runs SELECT 1 through the Data API as that DbUser, asserting the result. * test(compat): SDK coverage for Redshift GetClusterCredentials Adds getClusterCredentials and getClusterCredentialsWithIAM assertions to the AWS SDK Redshift compatibility test. * docs(redshift): document GetClusterCredentials and GetClusterCredentialsWithIAM Regenerates the redshift.md action table (excluding the DbGroups member-name switch label), fills the two new descriptions, updates the wire-auth and redshift-data.md DbUser notes, and bumps the Service Matrix count to 23. * fix(redshift): reject a wrong master password instead of passing it through passwordValidatorFor only treated the master pair as MASTER_EQUIVALENT and let everything else fall to the broker. A request with the master username but a wrong password is unknown to the broker, so it classified as PASSTHROUGH; the wire proxy then opened the backend leg as master (isMaster is username-only) and the client authenticated with the wrong password. Now the master username is decided on its own password: match to MASTER_EQUIVALENT, mismatch to REJECT. * fix(redshift): reject proxy logins when the cluster row is gone; strip IAM user path passwordValidatorFor fell through to the broker when the cluster was absent from the account partition, classifying an unknown user as PASSTHROUGH; the wire proxy reads isMaster from its own start-time config, so that still opened the backend as master for the master username with any password. Return REJECT when there is no cluster row to validate against. RedshiftIamDbUserResolver now strips an IAM path prefix from a user ARN (user/team/alice -> alice), matching how AWS names the DbUser. * fix(redshift): keep concurrent credentials, revoke on delete, bound the config default Addresses PR review (greptile): - RedshiftCredentialBroker now holds every unexpired credential per DbUser instead of one slot, so a reissue no longer invalidates a still-live password (matches AWS, which keeps each issued credential valid to its own expiry). - Add revokeCluster(); RedshiftService calls it on deleteCluster and at the start of createCluster, so a cluster recreated with the same identifier does not inherit master-equivalent access from a stale credential. - resolveDurationSeconds now holds the YAML default to the same 900-3600 bounds as a request value, falling back to 900 with a WARN instead of minting a credential that is already expired or over-range. * fix(redshift): revoke temp credentials on createCluster rollback too The greptile review asked for revocation on 'relevant rollback paths'. Both createCluster failure branches that delete the cluster row now also call credentialBroker.revokeCluster, so a credential issued by a concurrent GetClusterCredentials while the row briefly existed cannot outlive it. * fix(redshift): correct GetClusterCredentials AutoCreate prefix AWS prefixes the returned DbUser with IAM: when AutoCreate is false and IAMA: when it is true. The handler returned IAM: when true and no prefix when false, so a client using the returned name could not authenticate and the value diverged from GetClusterCredentialsWithIAM, which already issues prefixed identities. The broker keys on the returned name, so the proxy and Data API now expect the prefixed DbUser. Tests and the redshift docs are updated to match. * test(redshift): give compat GetClusterCredentials tests distinct @Order Three methods shared @Order(2), leaving their relative order undefined. Number the two credential tests 3 and 4 and move testDeleteCluster to 5. |
||
|
|
b9039fef1d |
feat(redshift-data): emulate the Amazon Redshift Data API (#3186)
* feat(redshift-data): resource resolver, connection factory, statement store, service registration * feat(redshift-data): field mapper, column metadata, SQL parameter binding * feat(redshift-data): execute, describe, and paged result retrieval * feat(redshift-data): batch execution, list statements, cancel * feat(redshift-data): schema introspection operations * test(redshift-data): end-to-end Data API over a real cluster plus SDK compatibility test * docs(redshift-data): document the Redshift Data API surface * fix(redshift-data): address code review findings - rejectMultiStatement now reuses the SQL tokenizer so a semicolon inside a comment, string literal, or dollar-quoted block no longer rejects a valid single statement - GetStatementResultV2 gains unit coverage for the typed and CSV envelopes - CSV output is RFC 4180 quoted (embedded comma, quote, CR, LF) - batch rollback is asserted transactionally in the integration test - RedshiftDataFieldMapper logs a swallowed blob-read SQLException - RedshiftPid/RedshiftQueryId use a non-negative hash - NextToken that decodes to a negative offset is rejected - CancelStatement leaves a FAILED statement FAILED - DescribeTable paginates ColumnList and emits NextToken - DbUser is echoed on the SecretArn path - the statement store no longer builds its sweeper executor in the test constructor * fix(redshift-data): address PR #3186 review findings - SQL scanner handles PostgreSQL escape strings (E'...'): a backslash-escaped quote no longer ends the literal and mis-detects a following :name as a bind marker; plain '...' literals still treat backslash as an ordinary character - ListStatements clamps MaxResults to 1..100 so MaxResults=0 no longer emits the same NextToken forever - DescribeTable matches Table / Schema exactly (=) instead of LIKE, so a name containing _ or % cannot merge other tables' columns into ColumnList - register the service in the README category table - drop a stray em dash from the neighbouring services.yaml comment * fix(redshift-data): bind string parameters untyped so real PostgreSQL infers the column type CI ran the integration test against a real Redshift (PostgreSQL 15) cluster and parameterisedStatement failed: a string bound to an int column via setString raised "operator does not exist: integer = character varying". H2 in PostgreSQL mode coerces it, so the unit test missed it. - RedshiftDataConnectionFactory adds stringtype=unspecified to the JDBC URL, so setString sends the value untyped and the server infers the target type, matching how AWS binds Redshift Data API parameters - ListStatements now rejects MaxResults above 100 with ValidationException instead of silently clamping (PR #3186 re-review) - RedshiftDataOperationsTest uses JBoss Logging, not java.util.logging (PR #3186 re-review) * fix(redshift-data): back the statement store with StorageFactory The store held a bare ConcurrentHashMap outside the configured storage and lifecycle model. It now obtains an account-aware backend through StorageFactory ("redshift-data", statements.json), the same as Athena's query store, resolved to the global storage mode via the catalog descriptor. Default mode stays memory, so statements are still lost on restart as documented; the 24h TTL sweep now walks every account partition and deletes per account since the sweep thread has no request context. StoredStatement is annotated for reflection and field-visible serialization so persistent modes round-trip it. * test(redshift-data): cover StoredStatement serialization round-trip and values() The StorageFactory-backed store serializes StoredStatement in persistent modes. Adds a round-trip test through the exact mapper PersistentStorage builds, covering the ArrayNode, enum, Instant, and nested sub-statement fields plus the field-visibility annotation, and a values() test. * fix(redshift-data): register the nested Status enum for reflection PersistedModelReflectionTest walks every type reachable from a StorageFactory persistence root; StoredStatement.status pointed at an unregistered enum, so native-image deserialization of a persisted statement would fail on restart. |