The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
NFS file handle question prathamesh Linux 0 06-02-2008 03:25 AM
Stale NFS file handle alphasahoo UNIX and Linux Applications 3 05-12-2008 01:31 PM
deleting a file name by its handle arunkumar_mca High Level Programming 5 11-21-2006 04:24 PM
Stale NFS file handle rein UNIX for Advanced & Expert Users 5 01-30-2005 01:30 PM
NFS file handle kazimir UNIX for Advanced & Expert Users 2 07-24-2002 01:11 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-22-2009
philplasma's Avatar
philplasma philplasma is offline
Registered User
  
 

Join Date: May 2007
Location: Quebec
Posts: 18
how to handle potential file contention

I need to change how a posting procedure currently works in order to improve load balancing but I am hitting a potential file contention problem that I was wondering if someone here could assist me with...

In a directory called FilePool I would have a bunch of files that are constantly coming in as follows:
File0001.GO
File0001.GOA
File0001.GOB
File0001.GOC
File0002.GO
File0002.GOA
File0002.GOB
File0002.GOC

The *.GO file for each batch of files is only written after the entire batch has been written, so the problem isn't that what is pulling these batches may conflict with what is writing them, but rather:

There are four processes that are each looking for the presence of a *.GO file in the FilePool directory. If one of these processes finds one, it takes the entire batch and moves it into that process' directory to process the batch.

These processes work quickly and it could be that two processes try to grab File0001.GO at the same time. Is there a way to
1 - have the first process lock File0001.GO if it isn't already locked and then move the whole batch
2 - have the process check if there is any other pid attached to that file first and then move it if there is none
3 - any other way that you would ensure that the file contention in this situation is handled?

Thank you for any assistance you can provide.
  #2 (permalink)  
Old 09-22-2009
varontron varontron is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 110
for #1, can you temporarily rename the file?
for #2, you can use
Code:
ps -eo pid,args|grep "*.GO$"

, or
Code:
ps -auxww|grep...

This will give you a list of process id's where the command args contain the filenames. 'man ps' for more info -- it's flavor-dependent, i.e., on solaris you might need /usr/ucb/ps instead (see this thread PS truncates the o/p)

Can you have your processes write to an index file? Each proc could then look in this file for exclusions (i.e., filename in file, omit it from search,) write to the index when it claims ownership, and remove the entry when complete.

Last edited by varontron; 09-22-2009 at 01:48 PM.. Reason: more info
  #3 (permalink)  
Old 09-22-2009
philplasma's Avatar
philplasma philplasma is offline
Registered User
  
 

Join Date: May 2007
Location: Quebec
Posts: 18
I'm going to try your renaming suggestion first - I've created a script in each of the two process directories to take the first *.GO file and mv it into the process folder. I am going to use at or cron to call these two scripts simultaneously and see what happens.
  #4 (permalink)  
Old 09-23-2009
garethr garethr is offline
Registered User
  
 

Join Date: May 2009
Location: England
Posts: 92
Presumably if you check the return value of mv for the rename then the one which attempts to run second will have failed and you can safely exit. Interestingly that avoids the race condition of trying to identically-named files at the same time.
Reply

Bookmarks

Tags
file contention

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 03:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0