server shit

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

server shit

Post by SHRIKEE »

ok,

please help me out on this one.

Again im walking in to error like these:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 194 bytes) in /var/www/html/plugins/serendipity_event_backup/serendipity_event_backup.php on line 420
And im thinking what did i do wrong to deserve this shit. Why am i seeing those. Ive allocated 32 mb to apache and yet it wont work. WHY!

Didnt i install a nessesary memory manager? or what else could be wrong? I have no clue and i cant find a satisfying anser on the net. I now am going to try and upgrade httpd and php maybe that helps but ANY comments and or ideas are welcome!

Im running fedora core 4_amd64 on a amd3000+ 64, 512mb ram, 40gb hdd.
apache 2.0.54 php5.0.4 mysql 4.1.11 <- trying to upgrade those

Thanks a bunch!
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Um...
Ive allocated 32 mb to apache and yet it wont work. WHY!
33554432 bytes/1024 = 32768 kbytes

32768/1024 = 32 Mbytes

So, I think your install is just big... Maybe try giving it more memory...
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

im not saying 33554432 bytes is 32mb ...

im saying i dont understand the error and mention ive allocated 32mb instead of the default 8mb to apache/php

the database is 2.8mb and the website itself is little over 30mb including all images
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Or you might try changing this block:

Code: Select all

			if ($what == "dataonly" OR $what == "data") {
				$insert_text .= "##\n";
				$insert_text .= "##		INSERT-data von Tabelle ".$table."\n";
				$insert_text .= "##\n";
				$R2 = serendipity_db_query("SELECT * FROM ".$table."");
				unset($THIS);
				if (is_array($R2) && count($R2) >= 1) {
					foreach ($R2 AS $THIS) {
						$insert_text .= "INSERT INTO ".$table." (";
						@reset ($THIS);
						unset($key);
						unset($val);
						$insert_text1 = '';
						$insert_text2 = '';
						foreach ($THIS as $key => $val) {
							if (!intval($key) AND $key != "0") {
								$insert_text1 .= "".$key.",";
								$insert_text2 .= "'".addslashes($val)."',";
							}
						}
						$insert_text1 = substr($insert_text1, 0, (strlen($insert_text1)-1));
						$insert_text2 = substr($insert_text2, 0, (strlen($insert_text2)-1));
						$insert_text .= $insert_text1.") VALUES (".$insert_text2.");\n";
					}
				}
			}
			if ($create_text != "") {
				$create_text = $sqltext.$create_text;
				if ($TXT=fopen($dateidir.$filetime."_CREATE_".$dateiname, "w")) {
					fputs($TXT,$create_text);
					fclose($TXT);
					chmod($dateidir.$filetime."_CREATE_".$dateiname, 0666);
				}
			}
			if ($insert_text != "") {
				$insert_text = $sqltext.$insert_text;
				if ($TXT=fopen($dateidir.$filetime."_INSERT_".$dateiname, "w")) {
					fputs($TXT,$insert_text);
					fclose($TXT);
					chmod($dateidir.$filetime."_INSERT_".$dateiname, 0666);
				}
			}
To something like this (which is entirely untested and may not work at all):

Code: Select all

			if ($what == "dataonly" OR $what == "data") {
				$insert_text .= "##\n";
				$insert_text .= "##		INSERT-data von Tabelle ".$table."\n";
				$insert_text .= "##\n";
				$R2 = serendipity_db_query("SELECT * FROM ".$table."");
				unset($THIS);
				if (is_array($R2) && count($R2) >= 1) {
				    if ($TXT=fopen($dateidir.$filetime."_INSERT_".$dateiname, "w")) {
				  	fputs($TXT,$sqltext);
					foreach ($R2 AS $THIS) {
						$insert_text = "INSERT INTO ".$table." (";
						@reset ($THIS);
						unset($key);
						unset($val);
						$insert_text1 = '';
						$insert_text2 = '';
						foreach ($THIS as $key => $val) {
							if (!intval($key) AND $key != "0") {
								$insert_text1 .= "".$key.",";
								$insert_text2 .= "'".addslashes($val)."',";
							}
						}
						$insert_text1 = substr($insert_text1, 0, (strlen($insert_text1)-1));
						$insert_text2 = substr($insert_text2, 0, (strlen($insert_text2)-1));
						$insert_text .= $insert_text1.") VALUES (".$insert_text2.");\n";
                                                fputs($TXT,$insert_text);
					}
					fclose($TXT);
					chmod($dateidir.$filetime."_INSERT_".$dateiname, 0666);
                                    }
				}
			}
			if ($create_text != "") {
				$create_text = $sqltext.$create_text;
				if ($TXT=fopen($dateidir.$filetime."_CREATE_".$dateiname, "w")) {
					fputs($TXT,$create_text);
					fclose($TXT);
					chmod($dateidir.$filetime."_CREATE_".$dateiname, 0666);
				}
			}
I am assuming that the problem is that the variable $insert_text is growing too large... The new code writes the file as it processes... Mind you, PHP might just keep the whole file in memory, so you would still have the same problem...

Plus, my code may not even be correctly formed, so you might have to troubleshoot missing semicolons and stuff...

EDIT: oh, and I don't have any idea of what the output will look like, so you will need to make sure the files can actually be imported (if it works at all)
Last edited by mgroeninger on Fri May 12, 2006 10:36 pm, edited 1 time in total.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

SHRIKEE wrote:im not saying 33554432 bytes is 32mb ...

im saying i dont understand the error and mention ive allocated 32mb
Yes... And what I am saying is that the error is complaining that it needs more then 32MB of RAM to do whatever it is trying to do...

The hint it gives you is:
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 194 bytes)
It is saying that your php process has exhuasted the whole 32MB of memory it has been given...

You have to remember that serendipity has some memory footprint as it is running (which Garvin knows off the top of his head, but I don't... :D )

So to back itself up it is going to need more memory than _just_ the size of the database and the files... But I don't use the backup plugin, so I can't even speculate on how much memory it would need...
SHRIKEE
Regular
Posts: 128
Joined: Tue Feb 21, 2006 2:49 am
Location: Netherlands
Contact:

Post by SHRIKEE »

ok, sounds logical.

but it worked untill the 25th of last month, thats when the last backup was made.

nothing really changed. this problem occured earlier... i then upped the memory from 16 to 32mb. this cant go on forever. just upping the limit is not a sollution to me.
My kingdom For i am king of my heap of trash

Developing code on:
Workstation: Windows 2000 sp4, TSW webcoder 2005
Server: fedora core 4 amd64, apache 2.0.54, php 5.0.4, mysql 4.1.11.
mgroeninger
Regular
Posts: 546
Joined: Mon Dec 20, 2004 11:57 pm
Contact:

Post by mgroeninger »

Yeah... having to give it more memory ever few months is a big problem...

Basically, it looks like that portion of the code parses through all the entries in the database, and puts them all into one big long string.

So as your database gets larger, that string will need more memory.

You could take a look at the plugin and play with changing it to write data out to disk as it is parsed, rather than keep it all in a variable (that is what my code aboe is aiming to do). I just don't know enough about php and how it handles files to say that it would work without experimenting with it.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

The backup plugin simply creates problems when your Database grows so large.

You should look into a different backup solution, like using a SSH/Bash script on your server. Using PHP to backup is not recommended because of exactly those reasons usually. :-)

The other way would be to try emptying large tables every month so that your dumps don't get so large.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply