This commit is contained in:
2020-05-27 19:41:26 +00:00
parent 5449632edc
commit f9f29eedad
6 changed files with 79 additions and 14 deletions

View File

@@ -1,6 +1,48 @@
{"login": "manager","password": "l3tm3in"}
todo: MAYBE a datetime kind of parameter is interpreted as LOCAL by the server on a route
so what the fuck
sent from client http://localhost:7575/api/v8.0/server-metric?maxRecords=400&tsStart=2020-05-27T13:07:39.068Z&tsEnd=2020-05-27T19:07:40.068Z
At server route: tsStart: {2020-05-27 6:07:39 AM} tsEnd: {2020-05-27 12:07:40 PM} Kind=local for both
so actually that's all good so far, how about the query itself?
2020-05-27 12:13:38.6439|DEBUG|Microsoft.EntityFrameworkCore.Database.Command|Executing DbCommand [Parameters=[@__tsStart_0='2020-05-27T06:13:32' (DbType = DateTime), @__tsEnd_1='2020-05-27T12:13:33' (DbType = DateTime)], CommandType='Text', CommandTimeout='30']
SELECT a.t, a.allocated, a.cpu, a.gen0, a.gen1, a.gen2, a.privatebytes, a.workingset
FROM ametricmm AS a
WHERE (a.t >= @__tsStart_0) AND (a.t <= @__tsEnd_1)
ORDER BY a.t DESC
2020-05-27 12:13:38.8848|INFO|Microsoft.EntityFrameworkCore.Database.Command|Executed DbCommand (241ms) [Parameters=[@__tsStart_0='2020-05-27T06:13:32' (DbType = DateTime), @__tsEnd_1='2020-05-27T12:13:33' (DbType = DateTime)], CommandType='Text', CommandTimeout='30']
SELECT a.t, a.allocated, a.cpu, a.gen0, a.gen1, a.gen2, a.privatebytes, a.workingset
FROM ametricmm AS a
WHERE (a.t >= @__tsStart_0) AND (a.t <= @__tsEnd_1)
ORDER BY a.t DESC
Well, shit. The query is sending local time to the db server, so any query that sends to teh server needs teh values converted to utc first
This is malarky pure and simple!
:)
If change parameters to DateTimeOffset from DateTime and rerun exact steps as above:
2020-05-27 12:21:49.8196|INFO|Microsoft.EntityFrameworkCore.Database.Command|Executed DbCommand (21ms) [Parameters=[@__tsStart_0='2020-05-27T13:21:48.4840000+00:00', @__tsEnd_1='2020-05-27T19:21:49.4840000+00:00'], CommandType='Text', CommandTimeout='30']
SELECT a.t, a.allocated, a.cpu, a.gen0, a.gen1, a.gen2, a.privatebytes, a.workingset
FROM ametricmm AS a
WHERE (CAST(a.t AS timestamp with time zone) >= @__tsStart_0) AND (CAST(a.t AS timestamp with time zone) <= @__tsEnd_1)
ORDER BY a.t
* Now it properly is sending the value to the db in UTC as it stays IN utc from input to query
One thing though is it's casting the query to a timestamp with timezone which is weird but maybe because the column is defined as timestamp witout timezone
going to try
changing the model to datetimeoffset
change database schema for mmetric to with timezone
no, actually for me it's better without because it will never try to interpret or change it, it will just return and accept it as is and
that's what I want if I'm only dealing in UTC
rerun again and see if it's casting still
todo: leave running check it does overnight backup properly
todo: add backup turn off setting