diff --git a/experimental/gcp-log/internal/storage/storage.go b/experimental/gcp-log/internal/storage/storage.go index 7f781aa..8cb8317 100644 --- a/experimental/gcp-log/internal/storage/storage.go +++ b/experimental/gcp-log/internal/storage/storage.go @@ -141,7 +141,12 @@ func (c *Client) SetNextSeq(num uint64) { } // WriteCheckpoint stores a raw log checkpoint on GCS if it matches the -// generation that the client thinks the checkpoint is. +// generation that the client thinks the checkpoint is. The client updates the +// generation number of the checkpoint whenever ReadCheckpoint is called. +// +// This method will fail to write if 1) the checkpoint exists and the client +// has never read it or 2) the checkpoint has been updated since the client +// called ReadCheckpoint. func (c *Client) WriteCheckpoint(ctx context.Context, newCPRaw []byte) error { bkt := c.gcsClient.Bucket(c.bucket) obj := bkt.Object(layout.CheckpointPath) @@ -160,7 +165,6 @@ func (c *Client) WriteCheckpoint(ctx context.Context, newCPRaw []byte) error { if _, err := w.Write(newCPRaw); err != nil { return err } - c.checkpointGen++ return w.Close() }