Skip to content

Failed to retrieve tables

首先,你可以通过查看我们的状态页面来确认这是你项目特有的问题还是平台问题。

🌐 First, you can verify if this is isolated to your project or if it's a platform issue by viewing our status page.

如果没有问题,那么很可能是你的项目出了问题。

🌐 If there are no issues, then it's likely a problem with your project.

当 Studio(仪表板)无法从数据库中获取表时,就会发生这个错误。通常,这是因为数据库处于崩溃状态,这通常是由于内存不足导致的。尝试运行 SQL 查询通常会导致像这样的超时错误:

🌐 This error occurs when the Studio (dashboard) is unable to retrieve the tables from the database. Generally, this is because the database is in a crashed state, which usually happens due to an out of memory error. Trying to run a SQL query will often result in a timeout error like this:

1
connection terminated due to query timeout

通过 API 尝试连接到项目通常会收到 522 或 525 的响应代码。

🌐 Trying to connect to the project via the API will often result in a 522 or 525 response code.

为什么会这样 #

🌐 Why this happens

内存不足错误通常是因为数据库活动突然激增,或者长期处于高活动水平,无论是由于查询量大,还是查询非常复杂(或两者结合)。

🌐 Out of memory errors usually happen because of a sudden spike in database activity, or a sustained high level of activity, either due to a high volume of queries or very complex queries (or a combination of both).

请注意,Nano、Micro、小型和中型计算实例每天都有30分钟的突发容量,因此可能能够在短时间内处理持续的高活动,但无法应对突然的峰值。

🌐 Note that Nano, Micro, Small and Medium compute instances have 30 minutes of burst capacity on a daily basis so may be able to handle sustained high activity for a short period of time, but not sudden spikes.

下一步和预防措施 #

🌐 Next steps and preventative measures

首先:

🌐 First:

  • 立刻停止对数据库的任何正在进行的查询。
  • 一旦你确认没有大的正在运行查询(如果有,可能会再次崩溃),就可以从仪表板的项目设置里重启实例。你可以在这个页面操作。如果再次崩溃,重新查看日志以了解可能的原因。

一旦你确定不会出现崩溃循环,你可以查看以下步骤:

🌐 Once you are confident there will not be a crash loop, you can review the following steps:

  • 如果这是有意的活动(通常是上传或读取大量测试数据的情况),并且需要再次进行,请将请求分批处理成更小的块并减少并发,同时对选择查询实现分页。有关这里的一般想法的更多信息,请查看我们的查询优化文档
  • 如果这是无意的,仔细检查一下你的应用代码、边缘函数或者数据库函数里是否有递归调用。
  • 考虑一下你的表格和查询结构——如果你的表格很“宽”(列很多)或者里面有复杂的数据类型,可能值得重新审视一下你的架构。
  • 继续监控你项目的查询性能标签,如果还没启用的话,开启索引顾问——尤其是当有很多 select 查询时。
  • 如果在监控了你的更改后,你仍然没有看到改善,考虑升级计算资源,如果你认为这种活动水平将会成为常态。这会给你更多的内存来处理这样的任务。你可以在这里查看所有计算资源选项。

如果你想要每分钟有效地监控你项目的表现,你可以使用Metrics API

🌐 If you want to effectively monitor your project's performance minute by minute, you can use the Metrics API.