Schema not being used in simple query, Error Screen

Hi there,

We just upgraded our internal metabase (running in docker) from 0.37.0.1 to 0.40.1. When I click Ask a Question, Simple Question, select our database, select a schema, and click on a table, I see the following error:

ERROR: relation "public.share_token" does not exist Where: Remote SQL command: SELECT share_token_id, scope, scope_id, expires_at, created_at, modified_at FROM public.share_token

For some reason, metabase is using public.share_token instead of auth.share_token. Any reason it would do that?

Screenshot:

Here is a screenshot of selecting the schema:

Strangely, this issue doesn't happen with other schemas, just this auth schema.

Any hints?

Hi @seanatstreem
Please post "Diagnostic Info" from Admin > Troubleshooting.
And try doing a manual sync (Admin > Databases) and checking the logs (Admin > Troubleshooting > Logs)

{
  "browser-info": {
    "language": "en-US",
    "platform": "MacIntel",
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.12+7",
    "java.vendor": "Eclipse Foundation",
    "java.vendor.url": "https://adoptium.net/",
    "java.version": "11.0.12",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.12+7",
    "os.name": "Linux",
    "os.version": "4.14.243-185.433.amzn2.x86_64",
    "user.language": "en",
    "user.timezone": "GMT"
  },
  "metabase-info": {
    "databases": [
      "postgres",
      "bigquery"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "10.17"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.2.23"
      }
    },
    "run-mode": "prod",
    "version": {
      "date": "2021-10-21",
      "tag": "v0.41.1",
      "branch": "release-x.41.x",
      "hash": "76aa4a5"
    },
    "settings": {
      "report-timezone": "US/Pacific"
    }
  }
}

@seanatstreem The error seems to indicate you're querying Postgres.

So after you've done a manual sync, are you still having this problem? And are there any errors during sync?

I really cannot think of what could be the cause of this problem, but you've migrated many versions.

If this schema is critical, then I would recommend reverting to your backup and try a slower step-by-step upgrade, so you can see which version it stops working at.

I triggered the sync, and noticed an error in the logs (thank you!). It turns out our auth schema was a foreign schema, and the share_token table had been deleted, but the foreign schema hadn't been re-imported. Once I refreshed the foreign schema, all appears to be working again. Thank you!

Note that this wouldn't have had anything to do with the upgrade, it was just discovered at the same time. But thank you for your time.