Skip to content

Commit

Permalink
fix(bigtable): apply one server time to all mutations in a set
Browse files Browse the repository at this point in the history
This is an important semantic property of BigTable:

  "All mutations in a single write request have the same timestamp
  unless you override them."

  https://cloud.google.com/bigtable/docs/writes#write-types
  • Loading branch information
adg committed Dec 28, 2023
1 parent b2db89e commit 5d0313f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bigtable/bttest/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,9 @@ func (s *server) PingAndWarm(ctx context.Context, req *btpb.PingAndWarmRequest)
// fam should be a snapshot of the keys of tbl.families.
// It assumes r.mu is locked.
func applyMutations(tbl *table, r *row, muts []*btpb.Mutation, fs map[string]*columnFamily) error {
// Generate one server timestamp for all mutations in this sequence.
serverTime := newTimestamp()

for _, mut := range muts {
switch mut := mut.Mutation.(type) {
default:
Expand All @@ -1094,7 +1097,7 @@ func applyMutations(tbl *table, r *row, muts []*btpb.Mutation, fs map[string]*co
}
ts := set.TimestampMicros
if ts == -1 { // bigtable.ServerTime
ts = newTimestamp()
ts = serverTime
}
if !tbl.validTimestamp(ts) {
return fmt.Errorf("invalid timestamp %d", ts)
Expand Down

0 comments on commit 5d0313f

Please sign in to comment.