Skip to content

Commit

Permalink
follow ups to #2252
Browse files Browse the repository at this point in the history
- make flag non-experimental, and enable by default
- make continuous checkpoint feature conditional on enablement
  • Loading branch information
vroldanbet committed Feb 27, 2025
1 parent 478c1f2 commit 15861ec
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 25 deletions.
2 changes: 1 addition & 1 deletion internal/datastore/postgres/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const (
defaultExpirationDisabled = false
// no follower delay by default, it should only be set if using read replicas
defaultFollowerReadDelay = 0
defaultRevisionHeartbeat = false
defaultRevisionHeartbeat = true
)

// Option provides the facility to configure how clients within the
Expand Down
26 changes: 17 additions & 9 deletions internal/datastore/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,14 +312,17 @@ func newPostgresDatastore(
followerReadDelayNanos,
)

revisionHeartbeatQuery := fmt.Sprintf(
insertHeartBeatRevision,
colXID,
tableTransaction,
colTimestamp,
quantizationPeriodNanos,
colSnapshot,
)
var revisionHeartbeatQuery string
if config.revisionHeartbeatEnabled {
revisionHeartbeatQuery = fmt.Sprintf(
insertHeartBeatRevision,
colXID,
tableTransaction,
colTimestamp,
quantizationPeriodNanos,
colSnapshot,
)
}

validTransactionQuery := fmt.Sprintf(
queryValidTransaction,
Expand Down Expand Up @@ -732,6 +735,11 @@ func (pgd *pgDatastore) Features(ctx context.Context) (*datastore.Features, erro
}

func (pgd *pgDatastore) OfflineFeatures() (*datastore.Features, error) {
continuousCheckpointing := datastore.FeatureUnsupported
if pgd.revisionHeartbeatQuery != "" {
continuousCheckpointing = datastore.FeatureSupported
}

if pgd.watchEnabled {
return &datastore.Features{
Watch: datastore.Feature{
Expand All @@ -741,7 +749,7 @@ func (pgd *pgDatastore) OfflineFeatures() (*datastore.Features, error) {
Status: datastore.FeatureUnsupported,
},
ContinuousCheckpointing: datastore.Feature{
Status: datastore.FeatureSupported,
Status: continuousCheckpointing,
},
WatchEmitsImmediately: datastore.Feature{
Status: datastore.FeatureUnsupported,
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/datastore/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ type Config struct {
// Expermimental
ExperimentalColumnOptimization bool `debugmap:"visible"`
EnableExperimentalRelationshipExpiration bool `debugmap:"visible"`
EnableExperimentalRevisionHeartbeat bool `debugmap:"visible"`
EnableRevisionHeartbeat bool `debugmap:"visible"`
}

//go:generate go run github.com/ecordell/optgen -sensitive-field-name-matches uri,secure -output zz_generated.relintegritykey.options.go . RelIntegrityKey
Expand Down Expand Up @@ -628,7 +628,7 @@ func newPostgresPrimaryDatastore(ctx context.Context, opts Config) (datastore.Da
postgres.WatchBufferWriteTimeout(opts.WatchBufferWriteTimeout),
postgres.MigrationPhase(opts.MigrationPhase),
postgres.AllowedMigrations(opts.AllowedMigrations),
postgres.WithRevisionHeartbeat(opts.EnableExperimentalRevisionHeartbeat),
postgres.WithRevisionHeartbeat(opts.EnableRevisionHeartbeat),
}

commonOptions, err := commonPostgresDatastoreOptions(opts)
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/datastore/zz_generated.options.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pkg/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func RegisterServeFlags(cmd *cobra.Command, config *server.Config) error {
apiFlags.Uint32Var(&config.MaxDeleteRelationshipsLimit, "max-delete-relationships-limit", 1000, "maximum number of relationships that can be deleted in a single request")
apiFlags.Uint32Var(&config.MaxLookupResourcesLimit, "max-lookup-resources-limit", 1000, "maximum number of resources that can be looked up in a single request")
apiFlags.Uint32Var(&config.MaxBulkExportRelationshipsLimit, "max-bulk-export-relationships-limit", 10_000, "maximum number of relationships that can be exported in a single request")
apiFlags.BoolVar(&config.EnableRevisionHeartbeat, "enable-revision-heartbeat", true, "enables support for revision heartbeat, used to create a synthetic revision on an interval defined by the quantization window (postgres only)")

datastoreFlags := nfs.FlagSet(BoldBlue("Datastore"))
// Flags for the datastore
Expand Down Expand Up @@ -169,7 +170,6 @@ func RegisterServeFlags(cmd *cobra.Command, config *server.Config) error {
Msg("The old implementation of LookupResources is no longer available, and a `false` value is no longer valid. Please remove this flag.")
}

experimentalFlags.BoolVar(&config.EnableExperimentalRevisionHeartbeat, "enable-experimental-revision-heartbeat", false, "enables experimental support for postgres revision heartbeat, used to create a synthetic revision on a given interval (postgres only)")
experimentalFlags.BoolVar(&config.EnableExperimentalRelationshipExpiration, "enable-experimental-relationship-expiration", false, "enables experimental support for first-class relationship expiration")
experimentalFlags.BoolVar(&config.EnableExperimentalWatchableSchemaCache, "enable-experimental-watchable-schema-cache", false, "enables the experimental schema cache which makes use of the Watch API for automatic updates")
// TODO: these two could reasonably be put in either the Dispatch group or the Experimental group. Is there a preference?
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ type Config struct {
MaxBulkExportRelationshipsLimit uint32 `debugmap:"visible"`
EnableExperimentalLookupResources bool `debugmap:"visible"`
EnableExperimentalRelationshipExpiration bool `debugmap:"visible"`
EnableExperimentalRevisionHeartbeat bool `debugmap:"visible"`
EnableRevisionHeartbeat bool `debugmap:"visible"`

// Additional Services
MetricsAPI util.HTTPServerConfig `debugmap:"visible"`
Expand Down Expand Up @@ -229,7 +229,7 @@ func (c *Config) Complete(ctx context.Context) (RunnableServer, error) {
// are at most the number of elements returned from a datastore query
datastorecfg.WithFilterMaximumIDCount(c.DispatchChunkSize),
datastorecfg.WithEnableExperimentalRelationshipExpiration(c.EnableExperimentalRelationshipExpiration),
datastorecfg.WithEnableExperimentalRevisionHeartbeat(c.EnableExperimentalRevisionHeartbeat),
datastorecfg.WithEnableRevisionHeartbeat(c.EnableRevisionHeartbeat),
)
if err != nil {
return nil, spiceerrors.NewTerminationErrorBuilder(fmt.Errorf("failed to create datastore: %w", err)).
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/server/zz_generated.options.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 15861ec

Please sign in to comment.