Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

adds uid_urlhash_idx on installation to support #42

Merged
merged 1 commit into from
Jan 26, 2021

Conversation

markhuot
Copy link
Collaborator

without this Postgres will complain that "ERROR: there is no unique or exclusion constraint matching the ON CONFLICT specification" with the following SQL,

INSERT INTO "upper_cache" ("urlHash", "url", "tags", "headers", "siteId", "dateCreated", "dateUpdated", "uid") VALUES ($1, $2, ARRAY[]::varchar[], $3, $4, $5, $6, $7) ON CONFLICT ("uid", "urlHash") DO UPDATE SET "urlHash"=$8, "url"=$9, "tags"=ARRAY[]::varchar[], "headers"=$10, "siteId"=$11, "dateCreated"=$12, "dateUpdated"=$13, "uid"=$14

Probably would need an additional migration for existing installations. If this makes sense I can make that migration before this merges.

without this Postgres will complain that "ERROR:  there is no unique or exclusion constraint matching the ON CONFLICT specification" with the following SQL,

INSERT INTO "upper_cache" ("urlHash", "url", "tags", "headers", "siteId", "dateCreated", "dateUpdated", "uid") VALUES ($1, $2, ARRAY[]::varchar[], $3, $4, $5, $6, $7) ON CONFLICT ("uid", "urlHash") DO UPDATE SET "urlHash"=$8, "url"=$9, "tags"=ARRAY[]::varchar[], "headers"=$10, "siteId"=$11, "dateCreated"=$12, "dateUpdated"=$13, "uid"=$14
@ostark ostark merged commit 032dd53 into ostark:master Jan 26, 2021
@timkelty
Copy link
Collaborator

timkelty commented Mar 4, 2021

@markhuot @ostark

So this got rid of the ON CONFLICT error, but replaced it with this:

sql_error_code = 23505 ERROR:  duplicate key value violates unique constraint "urlhash_idx"
sql_error_code = 23505 DETAIL:  Key ("urlHash")=(1ac88b98ff26828f9061fc9ac11d93d0) already exists.
sql_error_code = 23505 STATEMENT:  INSERT INTO "upper_cache" ("urlHash", "url", "tags", "headers", "siteId", "dateCreated", "dateUpdated", "uid") VALUES ($1, $2, ARRAY[]::varchar[], $3, $4, $5, $6, $7) ON CONFLICT ("uid", "urlHash") DO UPDATE SET "urlHash"=$8, "url"=$9, "tags"=ARRAY[]::varchar[], "headers"=$10, "siteId"=$11, "dateCreated"=$12, "dateUpdated"=$13, "uid"=$14

Likely related: yiisoft/db-pgsql#6

@markhuot
Copy link
Collaborator Author

markhuot commented Mar 4, 2021

Unfortunately, I believe that's expected for Postgres. I'd need to check it out, but I think Postgres reports that any time you do an ON CONFLICT…DO UPDATE query. Maybe there's a way to silent that notice?

@timkelty
Copy link
Collaborator

timkelty commented Mar 5, 2021

Worth noting that for many cases, simply setting useLocalTags to false takes any DB issues out of the equation.
I'm thinking we should maybe adjust that default dependent on the active driver? Eg, if Fastly (as it has tag invalidation), the default should be false.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants