Apparently, somehow, select now()
on my datagrip postgres connection was 20 minutes behind. Restarted datagrip and it's now fine. Before restarting I tried other db connections, they were fine. Coworker tried connecting themselves to the problem db and it was fine for them. How is that even possible? RDS Postgres (not aurora) 12, not that it matters I guess. My system clock was fine and doing select now()
against other similar RDS connections was fine too.
Asked
Active
Viewed 45 times
0

user433342
- 859
- 1
- 7
- 26
-
4Read [Current Date/timestamp](https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT): *... now() is a traditional PostgreSQL equivalent to transaction_timestamp().* which means `now()` gets the time at the beginning of a transaction and does not change in the transaction. So you had an open transaction: `BEGIN; now() ` and no `COMMIT` or `ROLLBACK`. What you are looking for is `statement_timestamp()` or `clock_timestamp()` depending on your needs. The docs answer most questions. – Adrian Klaver Apr 25 '23 at 20:37