Skip to content
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

Fixing redundant updates of session file #1006

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
pkRequest.Columns = append(pkRequest.Columns, ddl.IndexKey{ColId: pk.ColId, Order: pk.Order - decrement, Desc: pk.Desc})
}
}
primarykey.UpdatePrimaryKeyAndSessionFile(pkRequest)
primarykey.UpdatePrimaryKey(pkRequest)

Check warning on line 399 in webv2/api/rules.go

View check run for this annotation

Codecov / codecov/patch

webv2/api/rules.go#L399

Added line #L399 was not covered by tests
}
}

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 @@
setShardIdColumnAsPrimaryKeyPerTable(isAddedAtFirst, table)
addShardIdToForeignKeyPerTable(isAddedAtFirst, table)
addShardIdToReferencedTableFks(tableId, isAddedAtFirst)
session.UpdateSessionFile()

Check warning on line 1197 in webv2/api/schema.go

View check run for this annotation

Codecov / codecov/patch

webv2/api/schema.go#L1197

Added line #L1197 was not covered by tests
}
}
sessionState.Conv = conv
Expand Down Expand Up @@ -1712,7 +1713,7 @@
size := len(table.PrimaryKeys)
pkRequest.Columns = append(pkRequest.Columns, ddl.IndexKey{ColId: table.ShardIdColumn, Order: size + 1})
}
primarykey.UpdatePrimaryKeyAndSessionFile(pkRequest)
primarykey.UpdatePrimaryKey(pkRequest)

Check warning on line 1716 in webv2/api/schema.go

View check run for this annotation

Codecov / codecov/patch

webv2/api/schema.go#L1716

Added line #L1716 was not covered by tests
}

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()

VardhanThigle marked this conversation as resolved.
Show resolved Hide resolved
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()

}
Loading