Raised This Month: $32 Target: $400
 8% 

MYSQL NOW() Function broke


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rip1980
New Member
Join Date: Sep 2018
Old 09-28-2018 , 02:34   MYSQL NOW() Function broke
Reply With Quote #1

Hello-

I inherited a bunch of servers and website on a good sized community (original person got tired of it and I didn't want to see it die, so yay, more things for me to do.) I have extensive server exp and have run his for a long time, but not into modding at all.

I moved all his servers off his old box (dedicated, I think he was on redhat 6.5 or something) to a new baremetal box I put Ubuntu 18.04.1 on because, it's 2018 and RH annoys me (use it and centos at work all day, don't like the slow update schedule and this isn't production, so whatever.)

And possibly this isn't strictly an amxmodx problem as opposed to mysql.

Anyway, Custom/non-puiblic script from someone who's on this site but hasn't logged in for a long time, but basically keeps an SQL DB of a group of servers, players, open slot etc. and will give a popup menu in game with /servers to move between member servers.

Somewhere along the line, apparently the SQL NOW() function is broken in newer flavors of linux/mysql. Looking at the table redirects_data, everything is updating except for this datetime NOW() function.

This worked fine for years before the OS modernizing, and all other scripts and mods work, some very DB intensive.

Chunks of script (Every place NOW() Appears):

Code:
     formatex(cache, sizeof(cache)-1, "SELECT * FROM `redirects_data` WHERE unix_timestamp(NOW())-unix_timestamp(update_time)<22 LIMIT %d, %d;", g_p_start_num[id], g_p_start_num[id]+9)
    pos += formatex(cache[pos], sizeof(cache)-1-pos, "('%s', '%s', '%d', '%d', '%s', 'NOW()')", g_ip_port, quoted_hostname, pl, maxpl, map)
    pos += formatex(cache[pos], sizeof(cache)-1-pos, " ON DUPLICATE KEY UPDATE `pl`='%d', `maxpl`='%d', `map`='%s', `update_time`=NOW();", pl, maxpl, map)
Chunks of log:

Code:
[mysql_redirect.amxx] SQL Error (qh_update_data): Incorrect datetime value: 'NOW()' for column 'update_time' at row 1
Chunks of mysql log:
Brackets to hide use and db name, because I'm mental, but valid and correct/expected
Code:
2018-09-28T05:39:46.254913Z 134224 [Note] Aborted connection 134224 to db: '[VALID DB]' user: '[VALID USER]' host: 'localhost' (Got an error reading communication packets)
I'm hoping can shed some light on why this is broken and mitigations. I have some ideas based on 2 weeks of googling, but yeah, it's still broken. Thanks in advance!
rip1980 is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-28-2018 , 04:52   Re: MYSQL NOW() Function broke
Reply With Quote #2

Would you post the structure of the `redirects_data` table?
__________________
klippy is offline
Airkish
AlliedModders Donor
Join Date: Apr 2016
Location: Lithuania
Old 09-28-2018 , 06:28   Re: MYSQL NOW() Function broke
Reply With Quote #3

Show us values of update_time and it's TYPE
__________________
Airkish is offline
rip1980
New Member
Join Date: Sep 2018
Old 09-28-2018 , 23:28   Re: MYSQL NOW() Function broke
Reply With Quote #4

Thank you for the replies:

Structure:
Code:
 
1 	hostPrimary 	varchar(32) 	latin1_swedish_ci 		No 	None 	
2 	name 	        varchar(64) 	latin1_swedish_ci 		Yes 	NULL 			
3 	pl 	        int(11) 			                Yes 	NULL 				
4 	maxpl 	        int(11) 			                Yes 	NULL 			 	
5 	map 	        varchar(32) 	latin1_swedish_ci 		Yes 	NULL 			
6 	update_time 	datetime 			                Yes 	NULL
So across those field you would (and do, except datetime doesn't update anymore and throws an error in the script breaking it:

Code:
192.000.00.000:27015 	DEATHMATCH/ETC. 	3 	32 	fy_mapname 	2018-09-02 23:57:45
IP and port, Server Name, Players, Max Players, current map and update time

Each row updated for each member server, each server running this script reporting to the same SQL DB (all servers are on a dedicated box local, other SQL things work, and this script partially works. Maps, Players update OK.)
rip1980 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 09-29-2018 , 09:56   Re: MYSQL NOW() Function broke
Reply With Quote #5

Try changing

PHP Code:
'NOW()' 
to

PHP Code:
NOW() 
__________________
JusTGo is offline
rip1980
New Member
Join Date: Sep 2018
Old 10-04-2018 , 02:17   Re: MYSQL NOW() Function broke
Reply With Quote #6

Thanks for the reply.

I won't really have a chance to sit down and mess with it until the weekend (with any luck, have a family member on their way out, so that kinda takes precedence if needed. Don't wanna come off as not valuing your time or abandoning the topic if I don't get to it quickly.)

Thanks again.
rip1980 is offline
rip1980
New Member
Join Date: Sep 2018
Old 10-09-2018 , 00:39   Re: MYSQL NOW() Function broke
Reply With Quote #7

Thanks for your help.

That seems to be it, the single quotes. Probably something deprecated over time. The 2 systems I tried on are updating the Database as expected.

I am have compiling issues. the online compiler doesn't seem to accept files, and the pastebox appears to be filtering out back slashes, breaking lots of things.

Compiling on Linux, I get lots of errors:
Code:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2006 ITB CompuPhase, AMX Mod X Team

/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(214) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(215) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(217) : error 021: symbol already defined: "operator<=(Float:,Float:)"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(218) : error 021: symbol already defined: "40000005<=40000005"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(220) : error 021: symbol already defined: "operator<=(Float:,_:)"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(221) : error 021: symbol already defined: "40000005<=0"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(223) : error 021: symbol already defined: "operator<=(_:,Float:)"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(224) : error 021: symbol already defined: "0<=40000005"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(226) : error 021: symbol already defined: "operator!(Float:)"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(227) : error 021: symbol already defined: "!40000005"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(236) : error 021: symbol already defined: "floatmin"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(246) : error 021: symbol already defined: "floatmax"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/float.inc(255) : error 021: symbol already defined: "floatclamp"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/amxconst.inc(303) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/amxconst.inc(330) : warning 201: redefinition of constant/macro (symbol "LibType")
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/amxconst.inc(336) : warning 201: redefinition of constant/macro (symbol "AdminProp")
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/string.inc(270) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/string.inc(274) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/string.inc(276) : error 021: symbol already defined: "copy"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/string.inc(278) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/string.inc(286) : error 021: symbol already defined: "replace_all"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/lang.inc(57) : error 021: symbol already defined: "GetLangTransKey"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/lang.inc(57) : error 001: expected token: "=", but found "["
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/lang.inc(62) : error 021: symbol already defined: "AddTranslation"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/lang.inc(71) : error 021: symbol already defined: "LookupLangKey"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/messages.inc(94) : error 010: invalid function or declaration
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/messages.inc(98) : error 021: symbol already defined: "get_msg_args"
/home/csserver8/serverfiles/cstrike/addons/amxmodx/scripting/include/messages.inc(101) : error 021: symbol already defined: "get_msg_argtype"

Compilation aborted.
26 Errors.
64bit compiler failed to instantiate.


So will try later, need to get some sleep. I did pull down the AMXMODX studio, have tried Notepad++, WINSCP internal editor, and where I started, nano on linux, so....it's something stupid I'm sure.

So it's KINDA works on the pastebox compile, but menus are mangled because the menus and other text from the plugin use things like /d /y /w to format text.
rip1980 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 10-09-2018 , 05:42   Re: MYSQL NOW() Function broke
Reply With Quote #8

i guess you should compile the plugin locally the online compiler seems outdated.
__________________
JusTGo is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:31.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode