Skip to content

Invoke __identity_connected__ for sql http requests#2826

Closed
mamcx wants to merge 2 commits intomasterfrom
mamcx/invoke-identity-connected-sql
Closed

Invoke __identity_connected__ for sql http requests#2826
mamcx wants to merge 2 commits intomasterfrom
mamcx/invoke-identity-connected-sql

Conversation

@mamcx
Copy link
Contributor

@mamcx mamcx commented Jun 4, 2025

Description of Changes

Closes #2802

We invoke identity_connected for reducer calls over http but not for sql. This is a problem since identity_connected can have access control logic.

API and ABI breaking changes

Minor: It will run the on_connect and on_disconnect so in could reject calls that before run.

Expected complexity level and risk

1

Testing

  • Add smoke test

@mamcx mamcx self-assigned this Jun 4, 2025
@mamcx mamcx added release-any To be landed in any release window api-break A PR that makes an API breaking change labels Jun 4, 2025
@mamcx mamcx requested a review from coolreader18 June 4, 2025 16:18
Comment on lines +413 to +458
.leader(database.id)
.await
.map_err(log_and_500)?
.ok_or(StatusCode::NOT_FOUND)?;
let json = host.exec_sql(auth, database, body).await?;
let json = leader.exec_sql(auth, database, body).await?;

let total_duration = json.iter().fold(0, |acc, x| acc + x.total_duration_micros);

call_on_disconnect(module, connection_id, caller_identity).await?;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't ? on the result from exec_sql until after you call call_on_disconnect; otherwise, if the query fails for any reason, the module will never know that the client has disconnected. probably want something like

let json_result = exec_sql.await;
let disconn_result = call_on_disconnect.await;
let json = json_result?;
disconn_result?;

But that precise order of a sql error taking precedence over an on_disconnect error probably doesn't matter too much

@mamcx mamcx force-pushed the mamcx/invoke-identity-connected-sql branch 3 times, most recently from 94b95fe to 5a43886 Compare June 6, 2025 15:46
@mamcx mamcx force-pushed the mamcx/invoke-identity-connected-sql branch from dfd8eb1 to 44ce625 Compare June 6, 2025 16:24
@joshua-spacetime
Copy link
Collaborator

Superseded by #4563

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-break A PR that makes an API breaking change release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Invoke __identity_connected__ for sql http requests

3 participants