"Build all thumbnails/resizes" times out.

david.irwin-fam...

Joined: 2008-02-03
Posts: 6
Posted: Mon, 2008-11-17 20:54

Please could someone help me.

Problem (Cause)
I have uploaded my entire photo album to gallery2 and did so by uploading files without building thumbnails. I did this because many of my photo albums contain over 300 images, and the browser session was timing out if I uploaded more than about 70 images while creating the thumbnails (I have been using the "from local server" method of loading images). As a result visiting my albums for the first time takes a while (expected) but also sometimes gives me a error 500 from IIS (I assume the dynamic thumbnail build is taking too long). I would therefore like to trigger a build of the thumbnails, but running the maintenance job also times out in IIS with an error 500. Annoyingly IIS7 does not give any details or reasons on the error page.

Request (how I think this could be solved)
I would like to trigger the thumbnails and resized images to build from a command prompt if possible rather than through the browser interface so the IIS timeout is avoided. Is this possible?


Gallery version (not just "2"): 2.3 core 1.3.0
PHP version (e.g. 5.1.6): 5.2.6 cgi-fcgi
PHPInfo Link (see FAQ): http://davidi.no-ip.com/test.php
Webserver (e.g. Apache 1.3.33): IIS 7 (Windows Vista x64)
Database (e.g. MySql 5.0.32): MySQL 5.0
Activated toolkits (e.g. NetPbm, GD): ImageMagick 6.3.9 Q16, Jpegtran
Operating system (e.g. Linux): Windows Vista x64
Browser (e.g. Firefox 2.0): Firefox 3.0.4 and IE7 (latest updates)

 
david.irwin-fam...

Joined: 2008-02-03
Posts: 6
Posted: Sat, 2008-11-29 13:54

Moved this into the problems forum. Can someone help me please?

 
Bad921

Joined: 2008-11-29
Posts: 1
Posted: Sat, 2008-11-29 14:41

how do i change date on photos already uploaded

 
Joel_M_Miller

Joined: 2006-08-17
Posts: 33
Posted: Sat, 2008-11-29 18:40

I have had the same issue when trying to rebuild thumbnails. I have thousands of pictures in my galleries. I don't know of a way to do from a command line, but when I did was perform the rebuild thumbnails and it would time out after a little b it (maybe 200 pictures). I would then rebuld again and it seems to start where it left off and do another 200. I would keep doing this over and over until it was all done. This is tedious and time consuming, but it worked for me...

I agree that a command-line process would be great for issues like this.

 
Joel_M_Miller

Joined: 2006-08-17
Posts: 33
Posted: Sat, 2008-11-29 18:41

Bad921,
Please post a new thread instead of replying to someone else's issue. This will get you better results and it is considered very bad etiquette to ask a question under someone else's topic.

Thanks

 
david.irwin-fam...

Joined: 2008-02-03
Posts: 6
Posted: Sat, 2008-11-29 22:36

Joel,
Thank you for the comment.

Dave

 
Joel_M_Miller

Joined: 2006-08-17
Posts: 33
Posted: Sun, 2008-11-30 03:15

David,
Did this work for you? (I know its just a workaround...)

 
david.irwin-fam...

Joined: 2008-02-03
Posts: 6
Posted: Thu, 2008-12-04 22:03

Joel,
To be honest I am not sure yet - I am still seeing the timeouts when I run the build resizes/thumbnails, but then I have 8700 pictures in my albums, and I don't have that much patience at any given time!
I will run it through a few more times over this weekend and let you know if I get to the end!

Dave

 
mpak

Joined: 2008-12-09
Posts: 2
Posted: Tue, 2008-12-09 16:28

I have exactly the same problem - thumbnails build times out. I have tried to run it several times, but it looks like it times out at the same point - it does not pass over 330 photos..

any hints on how to generate thumbnails off-line?

 
david.irwin-fam...

Joined: 2008-02-03
Posts: 6
Posted: Thu, 2008-12-11 19:50

I am still struggling with this problem. It is really causing me some grief, and unfortunately may lead to me having to discard Gallery2 if I cannot find a solution.

Can anyone make a suggestion or recommendation for how to resolve this issue?

 
SinnerG

Joined: 2007-04-19
Posts: 58
Posted: Sun, 2009-04-26 16:18

Sorry, I know this thread is a few months old, but I too have had timeout issues with thumbnail rebuilds. This is usually due to the hosting service and their script timeouts. I moved the gallery to my local PC since I don't need it online anymore. Still plagued with thumbnail rebuild due to the number of images (147K of them).

I put this together last night after some digging in the php code:

<?php
set_time_limit(0);
// Do I need this one?
define('GALLERY_FORM_VARIABLE_PREFIX', 'g2_');

// Set this to the base directory of your gallery. This one here is
// for IIS. :P
define('MYBASEDIR', 'c:\inetpub\wwwroot\gallery2');
define('GALLERY_CONFIG_DIR', MYBASEDIR);

// Removed dirname(__FILE__) and set it to a fixed location.
require_once(MYBASEDIR . '/modules/core/classes/Gallery.class');
require_once(MYBASEDIR . '/modules/core/classes/GalleryDataCache.class');

$GLOBALS['gallery'] =& new Gallery();
$gallery =& $GLOBALS['gallery'];

@include(GALLERY_CONFIG_DIR . '/config.php');

// skipping everything for fastdownload in main.php and moving onto the init.inc load
require_once(dirname(__FILE__) . '/init.inc');
$ret = GalleryInitFirstPass();
if ($ret) {
	exit("Problem on GalleryInitFirstPass\n");
} else {
	echo "All good on GalleryInitFirstPass\n";
}

// Skip the GalleryMain() and _GalleryMain() calls and squeeze it all
// together into one.

/* Check all existing derivatives */
$query = '
SELECT
  [DerivativeImage::id]
FROM
  [DerivativeImage]
ORDER BY [DerivativeImage::id]
';
$gallery->guaranteeTimeLimit(120);
list ($ret, $derivatives) = $gallery->search($query);
if ($ret) {
	exit("Couldn't load derivative info\n");
}
else
	echo "Loaded derivatives info\n";

$i = $broken = $built = $skipped = 0;
	
$total = $derivatives->resultCount();
echo "Processing $total derivatives\n";
$gallery->guaranteeTimeLimit(120);
while ($result = $derivatives->nextResult()) {
	list ($ret, $derivative, $wasBuilt) =
	GalleryCoreApi::rebuildDerivativeCacheIfNotCurrent($result[0], true);
	$i++;
	if ($ret) {
		echo "\nError: building $result[0]: " . $ret->getAsHtml()."\n";
	}
	echo "Item $i: ";
	if ($ret || $derivative->getIsBroken()) {
		echo "oops .. derivative is broken\r";
		$broken++;
	} else if ($wasBuilt) {
		echo "...built ($built of $total)\r";
		$built++;
	} else {
		echo "...skipped\r";
		$skipped++;
	}
}

echo "\n\nProcess complete:\n\tProcess count: $i\n\tBuilt: $built\n\tBroken: $broken\n\tSkipped: $skipped\n\n";

$gallery->performShutdownActions();

$isinited = $gallery->isStorageInitialized();
if (!$isinited)
	exit("Storage not initialized\n");
else
	echo "Storage initialized\n";
	
$storage =& $gallery->getStorage();
$ret = $storage->commitTransaction();
if ($ret)
	exit("commitTransaction... me no likey\n");
else
	echo "commitTransaction successful\n";
?>

It's currently rebuilding my thumbnails offline, some 147000 of them. I've taken shortcuts, so you can run this at your own risk. So far, no issues. It simply does what the BuildDerivativesTask.class does to do the work just like gallery2 does, but I'm skipping out other stuff, etc. Ideally, this should call the BuildDerivativesTask class, but I didn't need the extra stuff.

Yes, this is on IIS (MYBASEDIR gives that away) against postgresql database.

I just have it as a php script on my machine and run it from command line and will set it up as a job later on.

 
msundman

Joined: 2007-11-20
Posts: 3
Posted: Sun, 2009-05-03 23:49
david.irwin-family.net wrote:
I have 8700 pictures in my albums, and I don't have that much patience at any given time!

Use the Opera browser, then right-click the "run now"-link on Build all thumbnails/resizes and select "Open in New Tab" and in the new tab right-click anywhere and select Reload Every -> 5 Seconds. Then you leave it running in the background for a few hours. (When its nearly done you can change it to Reload Every -> 30 Seconds, just so that it won't keep hammering the website after its done building all resizes before you notice it and turn off the auto-reload.)

 
SinnerG

Joined: 2007-04-19
Posts: 58
Posted: Mon, 2009-05-04 07:28

Wouldn't that be firing off the rebuild every 5 seconds then?

Sometimes I find it useful to dig up the related source file and look for guaranteeTimeLimit function calls that gallery makes and set them to something ridiculous. This sorted out an issue I had recently where a task (can't remember which one now) would just stop and leave a blank page. Setting the time limit to 5000 sorted it out. I have a huge gallery so most of the time the figures set for guaranteeTimeLimit don't quite apply.

 
msundman

Joined: 2007-11-20
Posts: 3
Posted: Mon, 2009-05-04 13:48
SinnerG wrote:
Wouldn't that be firing off the rebuild every 5 seconds then?

No, that timeout starts when the page has finished loading. So it might be rebuilding for 5 minutes and when the lock timeout or whatever error comes that causes the page to stop loading opera will wait 5 seconds and then reload the page causing the rebuilding to continue.

 
SinnerG

Joined: 2007-04-19
Posts: 58
Posted: Mon, 2009-05-04 13:53

Ah, I see. That will do nicely for those who don't want to dig into scripting jobs, etc.