Skip to content

Commit

Permalink
Fixing redundant updates of session file (#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
VardhanThigle authored Feb 5, 2025
1 parent 263e942 commit ff09f97
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion webv2/api/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ func revertShardIdColumnAsPrimaryKey(isAddedAtFirst bool) {
pkRequest.Columns = append(pkRequest.Columns, ddl.IndexKey{ColId: pk.ColId, Order: pk.Order - decrement, Desc: pk.Desc})
}
}
primarykey.UpdatePrimaryKeyAndSessionFile(pkRequest)
primarykey.UpdatePrimaryKey(pkRequest)
}
}

Expand Down
3 changes: 2 additions & 1 deletion webv2/api/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,7 @@ func (tableHandler *TableAPIHandler) restoreTableHelper(w http.ResponseWriter, t
setShardIdColumnAsPrimaryKeyPerTable(isAddedAtFirst, table)
addShardIdToForeignKeyPerTable(isAddedAtFirst, table)
addShardIdToReferencedTableFks(tableId, isAddedAtFirst)
session.UpdateSessionFile()
}
}
sessionState.Conv = conv
Expand Down Expand Up @@ -1712,7 +1713,7 @@ func setShardIdColumnAsPrimaryKeyPerTable(isAddedAtFirst bool, table ddl.CreateT
size := len(table.PrimaryKeys)
pkRequest.Columns = append(pkRequest.Columns, ddl.IndexKey{ColId: table.ShardIdColumn, Order: size + 1})
}
primarykey.UpdatePrimaryKeyAndSessionFile(pkRequest)
primarykey.UpdatePrimaryKey(pkRequest)
}

func addShardIdColumnToForeignKeys(isAddedAtFirst bool) {
Expand Down
6 changes: 3 additions & 3 deletions webv2/primarykey/primarykey_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func PrimaryKey(w http.ResponseWriter, r *http.Request) {

}

UpdatePrimaryKeyAndSessionFile(pkRequest)
UpdatePrimaryKey(pkRequest)
session.UpdateSessionFile()

convm := session.ConvWithMetadata{
SessionMetadata: sessionState.SessionMetadata,
Expand All @@ -113,7 +114,7 @@ func PrimaryKey(w http.ResponseWriter, r *http.Request) {
log.Println("request completed", "traceid", id.String(), "method", r.Method, "path", r.URL.Path, "remoteaddr", r.RemoteAddr)
}

func UpdatePrimaryKeyAndSessionFile(pkRequest PrimaryKeyRequest) {
func UpdatePrimaryKey(pkRequest PrimaryKeyRequest) {

sessionState := session.GetSessionState()
spannerTable, _ := getSpannerTable(sessionState, pkRequest)
Expand Down Expand Up @@ -150,6 +151,5 @@ func UpdatePrimaryKeyAndSessionFile(pkRequest PrimaryKeyRequest) {
}
common.ComputeNonKeyColumnSize(sessionState.Conv, pkRequest.TableId)
RemoveInterleave(sessionState.Conv, spannerTable)
session.UpdateSessionFile()

}

0 comments on commit ff09f97

Please sign in to comment.