Skip to content

Commit

Permalink
cli: warn the user if the time zone database is unavailable
Browse files Browse the repository at this point in the history
Release note (cli change): CockroachDB will now print out an error
message and an informative hint if the time zone database is unusable.
  • Loading branch information
knz committed Jun 17, 2019
1 parent 7a73e85 commit 375e7ed
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/cli/demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ func runDemo(cmd *cobra.Command, gen workload.Generator) error {
`, adminURL)
}

checkTzDatabaseAvailability(context.Background())

conn := makeSQLConn(connURL)
defer conn.Close()

Expand Down
14 changes: 14 additions & 0 deletions pkg/cli/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,11 @@ func runStart(cmd *cobra.Command, args []string) error {
// registered.
reportConfiguration(ctx)

// Until/unless CockroachDB embeds its own tz database, we want
// an early sanity check. It's better to inform the user early
// than to get surprising errors during SQL queries.
checkTzDatabaseAvailability(ctx)

// ReadyFn will be called when the server has started listening on
// its network sockets, but perhaps before it has done bootstrapping
// and thus before Start() completes.
Expand Down Expand Up @@ -916,6 +921,15 @@ func clientFlags() string {
return strings.Join(flags, " ")
}

func checkTzDatabaseAvailability(ctx context.Context) {
if _, err := timeutil.LoadLocation("America/New_York"); err != nil {
log.Shout(ctx, log.Severity_ERROR,
"unable to load named time zones, time zone support will be degraded.\n"+
"Hint: check that the time zone database is installed on your system, or\n"+
"set the ZONEINFO environment variable to a Go time zone .zip archive.")
}
}

func reportConfiguration(ctx context.Context) {
serverCfg.Report(ctx)
if envVarsUsed := envutil.GetEnvVarsUsed(); len(envVarsUsed) > 0 {
Expand Down

0 comments on commit 375e7ed

Please sign in to comment.