couchdb icon indicating copy to clipboard operation
couchdb copied to clipboard

time zone in log are different from os

Open fr2lancer opened this issue 2 years ago • 6 comments

Description

time zone in log are different from os

Steps to Reproduce

[error] 2023-11-21T00:24:57.206812Z [email protected] <0.26817.3> -------- CRASH REPORT Process (<0.26817.3>) with 1 neighbors exited with reason: killed at gen_server:decode_msg/9(line:481) <= proc_lib:init_p_do_apply/3(line:226); initial_call: {couch_replicator_httpc_pool,init,['Argument__1']}, ancestors: [<0.26813.3>,couch_replicator_scheduler_sup,couch_replicator_sup,...], message_queue_len: 1, links: [<0.28130.3>], dictionary: [], trap_exit: true, status: running, heap_size: 1598, stack_size: 29, reductions: 16778

[Shell] date Tue Nov 21 17:23:20 NZDT 2023

Expected Behaviour

Application follows the os time zone unless there is option to set.

Your Environment

  • CouchDB version used: Version 3.3.2

  • Operating system and version: RHEL8.8

Additional Context

similar issue : https://serverfault.com/questions/335232/how-to-change-couchdb-time-zone-setting-in-log-file

fr2lancer avatar Nov 21 '23 04:11 fr2lancer

This is not configurable (https://github.com/apache/couchdb/blob/main/src/couch_log/src/couch_log_util.erl#L40-L44)

couchdb will log timestamps as UTC (technically Posix Time which is close but not identical to UTC).

rnewson avatar Nov 21 '23 08:11 rnewson

@rnewson do you think it would make sense to make it configurable or to respect /etc/localtime as the submitter expects?

pgj avatar Nov 21 '23 12:11 pgj

Not in my opinion. The log is unambiguous (the ISO 8601 format includes the timezone indicator). Logs produced by couchdb installed anywhere are comparable without worrying about timezone differences.

We log as UTC (or close enough). Time zones are a rendering time issue. Users can, if they wish, translate these timestamps to their local time zone for display.

I'm strongly of the view that all servers (running couchdb or otherwise) should have their system time set to UTC regardless of location and timestamps should remain in UTC, but that's perhaps my bias working in an environment where I regularly interact with CouchDB's installed around the world.

rnewson avatar Nov 21 '23 12:11 rnewson

Okay, thanks. Differences in time zones for the timestamps should not cause problems as they indicate the time zone (as you highlighted) therefore logs would remain easily comparable, at least for machines.

I fully agree with you about running servers on UTC time — that is what I usually do myself whenever possible. I do not know how other applications handle or expected to handle this, but this issue gives me the feeling that CouchDB operates in a non-standard way in that regard and it should rely on the system time zone settings for the easier integration, even if that might not be practical.

pgj avatar Nov 21 '23 12:11 pgj

I've been doing this (couchdb) for too long so my horizon is narrowed, but I think it's at least not uncommon for application servers to log in UTC rather than local time. Of course other folks can provide their own opinions here. I wouldn't block a pull request that made this configurable, as long as the default remained UTC (/Posix Time). In ASF terms I'd be a -0. would prefer we didn't add this, but wouldn't block it.

rnewson avatar Nov 21 '23 13:11 rnewson

I’m not in favour of changing this unless a good reason is stated. I can imagine a scenario or two where this would be nice to have, but they are very uncommon. What Bob said.

janl avatar Nov 21 '23 13:11 janl