Kinto/kinto

Last modified field in collection is incorrect

Opened this issue · 7 comments

I am using Kinto on local server by installing on system. Kinto stores a 'last modified' data field whenever we insert a document in 'Kinto' collection. I found an issue with 'last modified' field whenever I inserted the data. The 'last modified' is an unix timestamp. I tried converting the unix timestamp to the Date format, and that doesn't matches with the time when the document was inserted. What's more fascinating is -
When I insert 2 documents consecutively, the 'last modified' timestamp when converted from unix to date format, varies hugely. Example -
new Date(1649841497793);
Wed Apr 13 2022 14:48:17 GMT+0530 (India Standard Time)
new Date(1649861297794);
Wed Apr 13 2022 20:18:17 GMT+0530 (India Standard Time)

Hi @vinod-mortgagekart, thank you for letting us know about this issue. I have a few questions:

  1. What operating system are you running Kinto server on?
  2. What database are you using Kinto with (memory or Postgres)? If Postgres, what operating system is the database running on?
  3. Can you provide your kinto.ini config for your server? Please redact any sensitive details.
  4. Can you provide the client code you're using to create these records?

Hi @dstaley , thanks for the response.

  1. I am running Kinto on Ubuntu system
  2. Postgres Database, the database is also running on ubuntu
  3. kinto.txt
  4. I am actually not sure, what do you mean by client code?

By client code I mean the code you used to insert consecutive records.

Oh, got it. So I am using python. I use the kinto_http library for interacting with Kinto. To insert consecutive records, I used a loop inside which 'create_record' method was used. Example - client.create_record(id = None,data = data,bucket = "default",collection = "test_data")
But, I don't think it's language dependent, as we are getting the same error using node.js

Oh, it's nice you've confirmed this happens with multiple clients! Can you also confirm that the Postgres database is configured to use UTC time zone? Also can you try your code again and share the timestamps you get? The two you shared are exactly 5.5 hours + 1 ms apart, so I'm curious if that's always the case. It would make sense that your Postgres DB is using India Standard Time since that's exactly 5.5 hours offset from UTC.

Yes, the postgres database is configured for UTC timezone using the query - 'SET TIME ZONE 'UTC' . I tried inserting the 4 documents consecutively, and all of them are 5.5 hrs apart.
1st - 1650557896877 - (Thursday, 21 April 2022 16:18:16.877) GMT
2nd - 1650577696878 - (Thursday, 21 April 2022 21:48:16.878) GMT
3rd - 1650597496879 - (Friday, 22 April 2022 03:18:16.879) GMT
4th - 1650617296880 - (Friday, 22 April 2022 08:48:16.880) GMT
'

The fact that each record is exactly 5.5 hours + 1 ms apart leads me to believe there's something wrong with either your Postgres configuration or your server configuration. When you run Kinto you should see output that starts with INFO [kinto.core] Running kinto 14.6.1. Can you check to see if that log has any mention of timezone issues? We recommend using ALTER DATABASE to set the timezone, so if you haven't done that give that a try.

Also, can you run SELECT last_modified FROM objects; to confirm that the timestamp in Postgres is matching the values being returned by the Kinto API?