Professional Web Applications Themes

blocking mysql to read - MySQL

Hi Everyone, I have a php batch job that i'd like to run on two machines. The batch job creates reports and sends them to my users. Im trying to develop a way that the scripts wont send the same report to my users twice. Does anyone have some suggestions on how to block one script from reading the table while the other script is reading the table? so for instace: in my table i have : * reports -- id -- status I want job #1 to read reports where status = 0 and then send them out then ...

  1. #1

    Default blocking mysql to read

    Hi Everyone,

    I have a php batch job that i'd like to run on two machines. The
    batch job creates reports and sends them to my users. Im trying to
    develop a way that the scripts wont send the same report to my users
    twice.

    Does anyone have some suggestions on how to block one script from
    reading the table while the other script is reading the table?

    so for instace: in my table i have :

    * reports
    -- id
    -- status

    I want job #1 to read reports where status = 0 and then send them out
    then update to status = 1.

    I dont want job #2 to be able to read the table in the mean time and
    run the same process.

    -d

    David Guest

  2. #2

    Default Re: blocking mysql to read

    Hello,

    David Wang <com> schrieb: 

    Do you understand the concept of transactions?

    kind regards,
    Andreas

    Andreas Guest

  3. #3

    Default Re: blocking mysql to read

    starting a transaction here would not help me as i'm trying to
    disallow a read of that specific row. the only thing that i've seen
    that may work is locking the entire table, but im not sure if that is
    the correct approach. suggestions?

    -d

    On Jun 25, 11:22 am, Andreas Stieger <de> wrote: 
    >
    > Do you understand the concept of transactions?
    >
    > kind regards,
    > Andreas[/ref]


    David Guest

  4. #4

    Default Re: blocking mysql to read

    David Wang <com> wrote in news:1182789456.165433.6730
    d30g2000prg.googlegroups.com:
     

    sounds it... better remember to unlock it, though!

    Good Guest

  5. #5

    Default Re: blocking mysql to read

    On Jun 25, 12:37 pm, David Wang <com> wrote: 

    > [/ref]


    >
    > - Show quoted text -[/ref]

    It sounds like a table lock (and yes, of course followed by an unlock)
    is what you need. If the total time your queries take while the table
    is locked is short then it shouldn't be a problem.

    Kevin Guest

  6. #6

    Default Re: blocking mysql to read

    Just wanted to give an update for other developers out there on what I
    did.

    To guarantee that each process didn't mash each other, i locked the
    table as well as did a select ... for update. it might be over kill
    but i got the best results with this and no mashing of data and no
    deadlock errors.

    thanks for all the suggestions!

    On Jun 28, 12:58 pm, Kevin Day <com> wrote: 


    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]
    > [/ref]

    >
    > It sounds like a table lock (and yes, of course followed by an unlock)
    > is what you need. If the total time your queries take while the table
    > is locked is short then it shouldn't be a problem.[/ref]


    David Guest

Similar Threads

  1. Read blob from mysql
    By Thierry in forum PHP Development
    Replies: 3
    Last Post: November 18th, 06:39 AM
  2. Non-Blocking read() failed on busy server
    By chaoith in forum UNIX Programming
    Replies: 4
    Last Post: September 26th, 10:25 AM
  3. Socket not blocking on read()
    By Charlie in forum UNIX Programming
    Replies: 5
    Last Post: September 19th, 03:29 PM
  4. Will Thread blocking in read() leads to process blocking?
    By Loic Domaigne in forum UNIX Programming
    Replies: 4
    Last Post: July 23rd, 12:36 PM
  5. pipe - non blocking read? (fork/Win32)
    By Stuart Moore in forum PERL Miscellaneous
    Replies: 6
    Last Post: July 7th, 03:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139