Skip to content

Conversation

@taimoorzaeem
Copy link
Collaborator

@taimoorzaeem
Copy link
Collaborator Author

I tested this manually using md5 hashes (cutting length to just 7 chars) as table names. The 4000 is not a good number and out of memory errors still occur with this setup.

According to my analysis, max 500 number of tables works best for fuzzy search even for 24 character long hashes as table names.

tableNotFoundHint :: Text -> Text -> [Table] -> Maybe Text
tableNotFoundHint schema tblName tblList
= fmap (\tbl -> "Perhaps you meant the table '" <> schema <> "." <> tbl <> "'") perhapsTable
| length tblList <= 4000 = fmap (\tbl -> "Perhaps you meant the table '" <> schema <> "." <> tbl <> "'") perhapsTable
Copy link
Contributor

Choose a reason for hiding this comment

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

There are several problems with this change:

length tblList complexity is linear in the list size and it has to iterate the whole list even if it is longer than 4k.

Leaving it like this opens up a DoS vulnerability.

4k is too many from my tests. On my machine PostgREST became unstable with 1k tables.
This is another DoS vulnerability.

Re-creating FuzzySet upon each request opens up yet another DoS vulnerability.

I'm afraid there is really no other sensible solution to this than #4472

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

4k is too many from my tests. On my machine PostgREST became unstable with 1k tables.

Yes, agreed. I was proposing 500 to be the upper limit as mentioned in #4523 (comment).

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

ServerDisconnectedError when querying tables created after PostgREST startup since v13+ Continuous memory growth and OOM kills since PostgREST v13+

2 participants