I assume I'm not the first person to have encountered this, but I
couldn't find anything in the FAQ or on the mailing lists recently.
My apologies if this is already documented somewhere...
My application logs data to a Postgres table continuously (once every
15 seconds), maintaining a persistent connection. Each datum is
logged with a time stamp (Postgres type "timestamp with time zone").
The application does not explicitly set the time zone, and does not
specify it when inserting the records. So everything just defaults to
the local time zone configured for the system, which is "US/Eastern".
This has been working fine all summer.
Until this morning, of course, when DST ended and "US/Eastern"
switched from GMT+4 to GMT+5. Everything logged fine up to 01:59 EDT
(05:59 UTC). Then the clock ticked to 01:00 EST (06:00 UTC), and I
got a unique constraint violation, because the database incorrectly
computed that I was trying to insert another record at 01:00 EDT
(05:00 UTC). I restarted the application when I noticed the problem
this morning, and now everything is working correctly.
My suspicion is that Postgres calculates the local offset from UTC
only once per session, during session initialization. Therefore, it
fails to notice when the local offset changes as a result of DST,
causing the problem I just described. It's hard for me to test this,
because I don't have a system I can freely muck with the clock on, but
it would completely explain this behavior.
Is this what's happening? Is it considered a bug? I can see making
the case for not changing the offset mid-session, but in that case it
should be explained more thoroughly in the documentation.
In my case, I think I'll have my app convert all times to UTC before
inserting them. This should avoid all such problems in the future.
PostgreSQL version (client and server) is 7.4.5, on i686 Debian sarge.
The client app is in python 2.3.4 using psycopg.
Thanks,
Randall Nortman
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Nov 23 '05
23 3772
On Mon, Nov 01, 2004 at 07:08:39PM +0100, Martijn van Oosterhout wrote: For the parsing integer issue it may have worked, but this is another kettle of fish. I don't think you can do this as a simple switch, it would have to set during the initdb and not allowed to be changed afterwards. I don't know if that something that can be supported.
I suspected it wasn't that easy. Anyhow, I strongly believe
that when no reasonable defaults can be deduced, the software
should give the user the ability to decide what he wants to do.
Of course technical (implementation , maintenance, etc.) issues are
highly relevant and if it can't reasonably be done, well, tough luck,
but I think (and I don't have a clue about the internals of
PostgreSQL, so take this with two grains of salt) a solution such
as the one you mention should be given consideration.
--
Vinko Vrsalovic <el[|-@-|]vinko.cl>
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
On Mon, Nov 01, 2004 at 07:08:39PM +0100, Martijn van Oosterhout wrote: For the parsing integer issue it may have worked, but this is another kettle of fish. I don't think you can do this as a simple switch, it would have to set during the initdb and not allowed to be changed afterwards. I don't know if that something that can be supported.
I suspected it wasn't that easy. Anyhow, I strongly believe
that when no reasonable defaults can be deduced, the software
should give the user the ability to decide what he wants to do.
Of course technical (implementation , maintenance, etc.) issues are
highly relevant and if it can't reasonably be done, well, tough luck,
but I think (and I don't have a clue about the internals of
PostgreSQL, so take this with two grains of salt) a solution such
as the one you mention should be given consideration.
--
Vinko Vrsalovic <el[|-@-|]vinko.cl>
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
On Sunday 31 October 2004 11:44 am, Tom Lane wrote: Randall Nortman <po***********@ wonderclown.com > writes: Ah, I see now. PostgreSQL is behaving a bit differently than I expected. The timestamp string above is ambiguous in the timezone US/Eastern -- it could be EST or EDT. I was expecting PostgreSQL to resolve this ambiguity based on the current time when the SQL statement is processed
I think this would be a very bad thing for it to do. It might seem to make sense for a timestamp representing "now", but as soon as you consider a timestamp that isn't "now" it becomes a sure way to shoot yourself in the foot.
Would it help to add the PG locale TZ to the insert statement? For
example the following queries return the TZ as text.
select to_char(now(),' tz');
to_char
---------
pst
select to_char(now()-'3 days'::interval ,'tz');
to_char
---------
pdt
So the following might fix this particular situation:
insert into sensor_readings _numeric (...) values (...,'2004-10-31
01:00:00 ' || to_char(now(),' tz'),...)
I realize that it assumes that the data is being inserted at the time
it was taken so a reading taken just before DST changes and inserted
just after will be incorrect but it may work for this particular app.
Of course the better solution is to have the application generate a
fully-qualified timestamp with time zone. Generating all the
timestamps in UTC and explicitly specifying that in the insert is
probably the easiest way to go. Your queries will still have your
local-appropriate TZ:
select '2004-10-31 00:00:00+00'::t imestamptz;
timestamptz
------------------------
2004-10-30 17:00:00-07
select '2004-11-01 00:00:00+00'::t imestamptz;
timestamptz
------------------------
2004-10-31 16:00:00-08
Cheers,
Steve
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings
On Sunday 31 October 2004 11:44 am, Tom Lane wrote: Randall Nortman <po***********@ wonderclown.com > writes: Ah, I see now. PostgreSQL is behaving a bit differently than I expected. The timestamp string above is ambiguous in the timezone US/Eastern -- it could be EST or EDT. I was expecting PostgreSQL to resolve this ambiguity based on the current time when the SQL statement is processed
I think this would be a very bad thing for it to do. It might seem to make sense for a timestamp representing "now", but as soon as you consider a timestamp that isn't "now" it becomes a sure way to shoot yourself in the foot.
Would it help to add the PG locale TZ to the insert statement? For
example the following queries return the TZ as text.
select to_char(now(),' tz');
to_char
---------
pst
select to_char(now()-'3 days'::interval ,'tz');
to_char
---------
pdt
So the following might fix this particular situation:
insert into sensor_readings _numeric (...) values (...,'2004-10-31
01:00:00 ' || to_char(now(),' tz'),...)
I realize that it assumes that the data is being inserted at the time
it was taken so a reading taken just before DST changes and inserted
just after will be incorrect but it may work for this particular app.
Of course the better solution is to have the application generate a
fully-qualified timestamp with time zone. Generating all the
timestamps in UTC and explicitly specifying that in the insert is
probably the easiest way to go. Your queries will still have your
local-appropriate TZ:
select '2004-10-31 00:00:00+00'::t imestamptz;
timestamptz
------------------------
2004-10-30 17:00:00-07
select '2004-11-01 00:00:00+00'::t imestamptz;
timestamptz
------------------------
2004-10-31 16:00:00-08
Cheers,
Steve
---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bathroom_Monkey |
last post by:
For posterity's sake, here is an algorithm I created to take a GMT
time and convert it to U.S. central time, accounting for daylight
saving time. Note: this algorithm can be modified to work for any
other U.S. timezone by changing the number of second subtracted at the
end.
<?
$in_dst="false";
|
by: ian douglas |
last post by:
Hey all.
I know with Perl "there's more than one way to do it", but I'd rather
not reinvent the wheel...
/usr/share/zoneinfo/Etc/
contains files like GMT-5 or GMT+8 etc which would be really handy for
me to tweak $ENV{'TZ'} to play with dates and times, but I'm trying to
find the 'best' approach to handle this scenario:
|
by: Ernie |
last post by:
I am creating an .ics file that when opened (via Outlook) inserts a
meeting into the calendar.
All works fine unless the date and time I'm inserting happens to occur
on the hour the time changes due to daylight savings.
For example in 2004 the hours changed at 2:00 AM on April 4th (the
first Sunday of April). Only on this day, if the start hour is 2 (2:00
AM, 2:15 AM, 2:45 AM), then an extra hour gets added so that 2:00 AM
becomes...
|
by: chrisdevey |
last post by:
Is there any way to make a System.Timers.Timer adjust for daylight
savings time change? In a long running process I set a timer as follows
for a daily expiration:
_myTimer = new Timer(_myTimerDelegate, null, nextExpiration,
TimeSpan.FromDays(1));
When we make the change out of daylight time back to standard time, the
timer appears to fire one hour early (e.g., 4pm instead of 5pm). Is
there a way to set this timer so that it is...
|
by: Randall Nortman |
last post by:
I assume I'm not the first person to have encountered this, but I
couldn't find anything in the FAQ or on the mailing lists recently.
My apologies if this is already documented somewhere...
My application logs data to a Postgres table continuously (once every
15 seconds), maintaining a persistent connection. Each datum is
logged with a time stamp (Postgres type "timestamp with time zone").
The application does not explicitly set the...
| |
by: Anna |
last post by:
Hi,
I've already found out that .Net Framework 1.1 does not properly handle
anything that is related to a non-current timezone. Since my project should
be released before the release of Framework 2.0, I am kindly asking if
anybody knows a workaround for the following:
My database stores various locations, and for each location we store a GMT
offset (number of hours). When the user selects a location, the program can
instantly obtain...
|
by: mmuras |
last post by:
I did not see any discussions / threads for this but if there is one please let me know:
-First, I am one of only two individuals within my company's IT Dept.
-We have a Windows Server 2003 R2 Standard Ed. Box for our Domain controller.
-We are having issues STILL today in April with the Microsoft Windows Daylight Savings Issues
***Symptoms:
|
by: Polaris431 |
last post by:
I have a web application in ASP.NET that will be used globally. Data
is collected on mobile devices running Windows Mobile and sent to the
web server where it is stored and can be viewed. Data is timestamped
when it is sent from a PDA device to the server. I am writing software
for both the web app and the PDA. The web server is located at one
location while the PDA devices are located around the world.
The question is, how do I handle...
|
by: Generic Usenet Account |
last post by:
Hi,
Is there any way to make time-of-day adjustments for daylight savings
using only standard time functions? We have a program that executes
daily at a fixed time of day. After daylight savings happens, the
time-of-day alignment is lost. For example, if the daily task gets
kicked in at 9 p.m. every evening, after daylight savings ends in
fall, the task is shown as kicking in at 8 p.m. Similarly, if the
daily task gets kicked in at...
|
by: RobG |
last post by:
I was investigating a function to determine whether daylight saving
was being observed on a particular date (given the platform's regional
settings) and came across a suggestion at merlyn.com to test the time
zone offset on a variety of dates to see if it changes. Based on
that, I developed the following checkDST() function which, as far as I
can tell, should be sufficient.
It checks either the date passed to it or the current date with...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |