Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db_mysql: Let the database convert the timestamp #957

Merged
merged 1 commit into from Feb 13, 2017

Conversation

zecke
Copy link
Contributor

@zecke zecke commented Jan 30, 2017

Instead of using the time2str routines that go through timezone
conversion in kamailio, let MySQL do it. This helps with the
sipcapture module in case the system time is CET but the database
is operated in UTC. In these cases the micro_ts and date columns
would be offseted by the timezone difference and look-ups fail
to work.

@zecke
Copy link
Contributor Author

zecke commented Jan 30, 2017

@adubovikov

@adubovikov
Copy link
Member

for me it's ok
@miconda ?

@miconda
Copy link
Member

miconda commented Jan 30, 2017

I think this can be added only as a modparam and disabled by default, because it can break the other modules that expect to store the server timestamp, like usrloc (location table), acc, msilo.

@adubovikov
Copy link
Member

@miconda you are right,

https://github.com/kamailio/kamailio/blob/master/src/lib/srdb1/db_ut.c#L211-L237

db_str2time expects the "original timestamp" in the kamailio's timezone.

@zecke can you please make it configurable ?

Add option to use FROM_UNUXTIME(time_t) instead of using the
time2str routines. This makes MySQL apply the database timezone
instead of using the localtime of the system inserting the data.

This is useful for the sipcapture module where the system time
might be in CET but the database is using UTC. In these cases
the micro_ts and the date columns were offseted by the timezone
difference.
@zecke
Copy link
Contributor Author

zecke commented Feb 1, 2017

Made it configurable but I have not tested/inserted data in a production system yet. So please wait for a second. I tried to update the documentation with the new parameter as well.

@zecke
Copy link
Contributor Author

zecke commented Feb 1, 2017

Okay it seems to work (on and off) of that setting. Used hepgen.js to send some data and had a breakpoint in the code in km_val.c and it was triggered (or wasn't depending on the global setting). _s also looked sane.

@juha-h
Copy link
Contributor

juha-h commented Feb 1, 2017 via email

@miconda
Copy link
Member

miconda commented Feb 9, 2017

@juha-h -- this seems to fix an issue when kamailio server (for sip routing) is different than kamailio server (for sipcapture). Overall is no change in the default behaviour, just a switch to choose the preferred date/time handling. It will be merged in master branch as the branch 5.0 was already created. But I will consider it for backporting if it looks clean and simple.

@miconda miconda merged commit 5612f7d into kamailio:master Feb 13, 2017
@zecke zecke deleted the db-mysql-datetime branch February 14, 2017 00:21
@zecke
Copy link
Contributor Author

zecke commented Feb 14, 2017

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants