-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
sql: default time zone should be customizable #16029
Comments
The default time zone in CockroachDB is always UTC and cannot (currently) be configured. We don't simply use the system time zone of the server because that may be configured differently across different nodes in the cluster, which would be very confusing. (Also, UTC is generally the right choice for a global application anyway) You can set the time zone for a session with the |
Coming from Mysql, it will be very useful if we can set the default time zone on CockroachDB. Hopefully, the will be implement in the near future. |
Retitled this issue. In mysql, it's common for client drivers to support setting the session time zone automatically, but this appears to be less common for postgres, so there's probably more need for a global time zone setting than I previously thought. We have cluster settings now, but I'm not sure if they're safe for the time zone setting as currently implemented. This would be the first setting (IIRC) that changes the semantics of SQL operations. Do we guarantee that newly-started nodes wait for the cluster settings to be available before serving any traffic, or is it possible for a node to serve its first few queries using the defaults? cc @dt |
I think a node currently can start serving queries before receiving gossiped settings, or certainly at least before loading received settings, given that that happens on a dedicated goroutine. We could introduce a wait group and block the serving startup, but, if a brief read of a default would cause a problem though for some setting, it suggests that changing the setting, which also happens though gossip and thus might arrive at a particular node a before or after some other node, would also be a problem, and the maybe that parameter just isn't a good fit for a runtime-changable setting. We could introduce another class of setting that is read transactionally whenever it is used, but that would obviously be (prohibitively?) expensive. |
I think it's OK that changing the time zone would have inconsistent effects across the cluster, but right now it wouldn't be safe to use a non-default time zone in the presence of any sort of automated provisioning of new servers, even if you set it once and never change it. However, the presence of limitations like the inability to change a setting at run time is one reason why setting a database-level time zone should be discouraged in favor of controlling the time zone in the application. It is low priority IMHO to provide this feature in the database. |
Oh, and more specifically for this issue: |
I think we have #15301 filed already for initial settings. |
I think that only allowing UTC on database level makes sense, if you want to present data in some other timezone (possibly multiple timezones) then that is up to the application/frontend to convert and present. |
The postgres |
We have marked this issue as stale because it has been inactive for |
This issue is superseded by the following:
|
cockroach version : 1.0
when cockroach started, default time zone is wrong.
my mac's default time zone is UTC+8
cockroach's default time zone is UTC
I170519 06:05:59.177794 1 util/log/clog.go:1011 [config] file created at: 2017/05/19 06:05:59
I170519 06:05:59.177794 1 util/log/clog.go:1011 [config] running on machine: df-macpro-home
I170519 06:05:59.177794 1 util/log/clog.go:1011 [config] binary: CockroachDB CCL v1.0 (darwin amd64, built 2017/05/18 21:50:42, go1.8.1)
I170519 06:05:59.177794 1 util/log/clog.go:1011 [config] arguments: [cockroach start --insecure --host=localhost]
The text was updated successfully, but these errors were encountered: