If you're dealing with multiple servers you won't really be able to
get away with just using cflock... even with a named lock, the lock is
only scoped to an individual server... so you'll have to resort to
some other means of determining if the file is in use by one of the
other servers... you could possibly use a stored procedure in your
database... something like

WHILE exists
(select * from mytable
where filename = @myfilename)
BEGIN
  /* do nothing -- we're just waiting to get the file */
END

INSERT INTO mytable (filename,server)
values (@myfilename,@myserver)

You might want to put this stored procedure in a cftransaction just
for good measure. When the procedure ends the file is locked for the
current server, then you can append your data and delete the record
from the table either with another procedure or an ad-hoc query.

hth

s. isaac dealey   954.927.5117

new epoch : isn't it time for a change?

add features without fixtures with
the onTap open source framework
http://www.sys-con.com/story/?storyid=44477&DE=1

> I've been up for 18 hours... so I'm definitely sharp
> today.  We've got
> an operation that needs to append to a single CSV.  The
> request could
> come from any one of four load balanced servers to a
> single netapp filer
> system.  The problem is the occasional race condition
> where the CSV will
> be in the process of being written to by one of the CF
> servers, and the
> other one needs to wait its turn like a good CF server, or
> risk being
> sent to bed without its dessert.

> I can't use CFLOCK with a file operation can I?  It's easy
> enough to
> CFTRY CFCATCH the file operation, but when it fails, I
> want it to keep
> trying until it gets a chance (within reason, of course -
> maybe 20 tries
> before failing), since it will only be a few milliseconds
> before its
> chance comes up.  I'd like to avoid the ignominious coding
> mess of
> stacking retries in CFCATCH blocks, and there must be a
> more graceful
> way of doing this, but I can't think of it.  Any ideas?

> - Jim
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to