Repository navigation
fix(storage-postgres): return UpdateTable before the GSI backfill finishes #708
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
base: main
Are you sure you want to change the base?
Changes from all commits
5a9eeef
c5f8fba
c05494b
14365b5
aada58f
d0ee181
1a9b9a6
5b70d1f
49fc116
15d43da
17a11a4
534932d
3126e91
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -566,22 +566,34 @@ impl PostgresEngine { | |
| index_name: &str, | ||
| ) -> Result<IndexInfo, StorageError> { | ||
| // A GSI still being built is not readable: its table is partial, or not | ||
| // there yet. The service answers a Query or Scan naming one with "The | ||
| // table does not have the specified index", the same as for no index at | ||
| // all, which is what `IndexNotFound` becomes on the wire. | ||
| let idx_row: Option<(String, String, serde_json::Value, serde_json::Value)> = | ||
| // there yet. In its backfilling phase the service refuses a Query or | ||
| // Scan naming one with "Cannot read from backfilling global secondary | ||
| // index: <name>". Measured 2026-10-30 on six index builds on four | ||
| // tables: DescribeTable reported `Backfilling` true 16 to 39 s after | ||
| // UpdateTable. On two tables the first Query and Scan sent after that, | ||
| // about two minutes after UpdateTable, got the backfilling text. On a | ||
| // third, Queries 0 and 2 s after `Backfilling` turned true still got | ||
| // "The table does not have the specified index", the answer before it | ||
| // turned true, and Queries about 45 s after it got the backfilling | ||
| // text. This backend has no allocation phase, so every CREATING index | ||
| // gets the backfilling refusal, which the engine answers with that text | ||
| // for a Query or Scan and as a missing index for a PartiQL statement. | ||
| let idx_row: Option<(String, String, String, serde_json::Value, serde_json::Value)> = | ||
| sqlx::query_as( | ||
| "SELECT index_type, index_id, key_schema, projection FROM indexes \ | ||
| WHERE table_id = $1 AND index_name = $2 AND index_status <> 'CREATING'", | ||
| "SELECT index_type, index_id, index_status, key_schema, projection \ | ||
| FROM indexes WHERE table_id = $1 AND index_name = $2", | ||
| ) | ||
| .bind(table_id) | ||
| .bind(index_name) | ||
| .fetch_optional(&self.pool) | ||
| .await | ||
| .map_err(|e| StorageError::Internal(e.to_string()))?; | ||
|
|
||
| let (idx_type_str, idx_id, ks_json, proj_json) = | ||
| let (idx_type_str, idx_id, idx_status, ks_json, proj_json) = | ||
| idx_row.ok_or_else(|| StorageError::IndexNotFound(index_name.to_owned()))?; | ||
| if idx_status == "CREATING" { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This refusal also reaches the PartiQL callers of
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I reproduced this through Fixed in The refusal is now its own variant, The new test |
||
| return Err(StorageError::IndexBackfilling(index_name.to_owned())); | ||
| } | ||
|
|
||
| let index_type = match idx_type_str.as_str() { | ||
| "GSI" => IndexType::Gsi, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A PartiQL read of a CREATING index answers as if the index did not exist, and every UpdateTable now opens that window. On the service in the backfilling phase, ExecuteStatement
SELECTwith WHERE on the index key, onpkor with no WHERE answersCannot read from backfilling global secondary index: gsi1, with ConsistentRead trueStrongly consistent read is not supported on Global Secondary Indexes, and inside BatchExecuteStatementSelect statements within BatchExecuteStatement must specify the primary key in the where clause.as for an ACTIVE index; this head and main giveThe table does not have the specified indexon all 20 shapes, twice. The comment, design section 6.2 and the body say this was not measured. Treating a backfilling index as existing for these checks and refusing at the read would match; otherwise a differences row would say it.