Skip to content
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

Import with many application roles cause a PostgreSQL exception #505

Closed
robotdan opened this issue Mar 5, 2020 · 0 comments
Closed

Import with many application roles cause a PostgreSQL exception #505

robotdan opened this issue Mar 5, 2020 · 0 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@robotdan
Copy link
Member

robotdan commented Mar 5, 2020

Import with many application roles cause a PostgreSQL exception

Description

When using PostgreSQL and using the Import API with many application roles, a PostgreSQL limit may be exceeded that will cause an exception.

PostgreSQL seems to be using a 2 byte integer to address the number of parameters in a prepared statement. A 2 byte integer has a max value of 32767 and once this is exceeded it cannot address the parameters and blows chunks.

I don't know for sure if this is a just a limitation of the PostgreSQL JDBC driver, or if this is defined by the PostgreSQL server. In any case, it doesn't work.

Caused by: java.io.IOException: Tried to send an out-of-range integer as a 2-byte value: 35442
    at org.postgresql.core.PGStream.sendInteger2(PGStream.java:266)
    at org.postgresql.core.v3.QueryExecutorImpl.sendParse(QueryExecutorImpl.java:1492)
    at org.postgresql.core.v3.QueryExecutorImpl.sendOneQuery(QueryExecutorImpl.java:1815)
    at org.postgresql.core.v3.QueryExecutorImpl.sendQuery(QueryExecutorImpl.java:1378)

In code path

at com.sun.proxy.$Proxy73.addRolesToUserRegistrationBulk(Unknown Source)
    at io.fusionauth.api.service.user.DefaultUserService.processRegistrations(DefaultUserService.java:1903)

Thanks to @leafknode for reporting the issue and assisting with debug.

Steps to reproduce

  1. Call the Import API with 5k users
  2. Each user having two registrations each with 20 application roles

Expected behavior

No exceptions.

Platform

PostgreSQL only, MySQL does not seem to fail this same scenario.

Additional context

@robotdan robotdan self-assigned this Mar 5, 2020
@robotdan robotdan added the bug Something isn't working label Mar 5, 2020
@robotdan robotdan added this to Backlog in FusionAuth Issues via automation Mar 5, 2020
@robotdan robotdan moved this from Backlog to On Deck in FusionAuth Issues Mar 5, 2020
@robotdan robotdan moved this from On Deck to In progress in FusionAuth Issues Mar 5, 2020
@robotdan robotdan added this to the 1.15.4 milestone Mar 9, 2020
@robotdan robotdan moved this from In progress to Code complete in FusionAuth Issues Mar 9, 2020
@robotdan robotdan moved this from Code complete to Done in FusionAuth Issues Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
FusionAuth Issues
  
Delivered
Development

No branches or pull requests

1 participant