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

mysql takes some time to perform timeshift #112

Closed
ValentinaBaranova opened this issue May 4, 2017 · 4 comments
Closed

mysql takes some time to perform timeshift #112

ValentinaBaranova opened this issue May 4, 2017 · 4 comments

Comments

@ValentinaBaranova
Copy link

I've tried to use libfaketime in the docker container with mysql. When I shift time, it implements immidiately if I use date function, but when I perform "select now()" it takes some time. I've tried to use FAKETIME_NO_CACHE, but it doesn't affect. Is it expected? I wanted to use libfaketime for integration tests so it makes tests slower.

root@b4ba87a2d32b:/# mysql -h127.0.0.1 -uUSER -pXXX -e "select now()"; echo -e "+2d" > /etc/faketimerc; mysql -h127.0.0.1 -uUSER -pXXX -e "select now()";
Warning: Using a password on the command line interface can be insecure.
+---------------------+
| now() |
+---------------------+
| 2017-05-04 14:22:59 |
+---------------------+
Warning: Using a password on the command line interface can be insecure.
+---------------------+
| now() |
+---------------------+
| 2017-05-04 14:22:59 |
+---------------------+
root@b4ba87a2d32b:/# mysql -h127.0.0.1 -uUSER -pXXX -e "select now()";
Warning: Using a password on the command line interface can be insecure.
+---------------------+
| now() |
+---------------------+
| 2017-05-04 14:23:01 |
+---------------------+
root@b4ba87a2d32b:/# mysql -h127.0.0.1 -uUSER -pXXX -e "select now()";
Warning: Using a password on the command line interface can be insecure.
+---------------------+
| now() |
+---------------------+
| 2017-05-04 14:23:02 |
+---------------------+
root@b4ba87a2d32b:/# mysql -h127.0.0.1 -uUSER -pXXX -e "select now()";
Warning: Using a password on the command line interface can be insecure.
+---------------------+
| now() |
+---------------------+
| 2017-05-06 14:23:06 |
+---------------------+
root@b4ba87a2d32b:/# date; echo -e "+3d" > /etc/faketimerc; date
Sat May 6 14:23:37 MSK 2017
Sun May 7 14:23:37 MSK 2017

@slertt
Copy link

slertt commented May 9, 2017

Hi @v4umak ,

did you find solution? Can you also post LD_PRELOAD ?

I'm trying the same thing but mysql statements are not affected by faketime but PHP scripts are.
My LD_PRELOAD:
` export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/faketime/libfaketime.so.1 FAKETIME="+1y" FAKETIME_NO_CACHE=1 mysql

results:
MySQL

+---------------------+
| NOW() |
+---------------------+
| 2017-05-09 15:24:11 |
+---------------------+

PHP script (echo date('l jS \of F Y h:i:s A');)
Wednesday 9th of May 2018 03:24:11 PM

As you can see, both are triggered at the same time, but mysql doesn't use faketime library.

`

@wolfcw
Copy link
Owner

wolfcw commented May 19, 2017

Well, I might be completely mistaken, but when you run the "select now()" query with a mysql client, doesn't it fetch the time from the mysql server and simply displays it?

In other words, are you trying to use libfaketime on the mysql client or on the mysql server?

I don't think changing a mysql client's system time (via libfaketime or otherwise) will have any effect on the time reported by the mysql server.

But I don't know the details of how the mysql client is implemented, so this may be a red herring. :-)

@slertt
Copy link

slertt commented May 22, 2017

MySQL server is running inside docker container (Debian) along with nginx and PHP.
And as you can see, PHP returns faked time where MySQL does not. And they are both running in the same container.
The script is run inside that container, so on the server.

@wolfcw
Copy link
Owner

wolfcw commented Nov 17, 2017

Looks like the mysql server (mysqld) is not properly started with faketime. Local time (or using faketime) for the mysql client is irrelevant.

@wolfcw wolfcw closed this as completed Nov 17, 2017
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

No branches or pull requests

3 participants