• Post Reply Bookmark Topic Watch Topic
  • New Topic

Any design pattern for following Producer/Conumer problem  RSS feed

 
Vijaishanker bala
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I dont know if this is the right place to post this problem. I am designing an enterprise search application. In the application, an Indexer process updates/creates an index in the file system and a web service accesses this updated/created index. My problem is when the webservice is querying the index, I am unable to update it which I guess is typical of the producer/consumer problem. What would be the best work-around for this problem,

Thanks

Vijai
 
Ådne Brunborg
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What seems to happen is that the WS query locks the database for reading and updating during a query.

you should look into isolation levels used when interacting with the database, to see if you can set the WS to not lock the db at all during a Read. Use care, since you' might end up have dirty reads, unrepeatable reads and/or phantom reads - basically, the data you read with your WS might be out of sync with the database even as you read them. This should not be a critical issue here, though, since the WS only performs Read operations on the db.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read the OP to be about file systems, not databases. I suppose I have the same issue with Lucene in my Wiki ... I update the index on every page save event, and during that update queries are blocked. Or at least they should be.

I'm trying to picture some kind of signal for threads. As long as only read threads come along we can let them run. If a write thread comes along we block new reads and wait for all current reads to finish, then run the write, then unblock the read threads. Is that the kind of thing you're expecting?
 
Tim LeMaster
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have the query read one index and the update write another. After the update is done it locks out all access to the online (read) index while it briefly copies the new index file in.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice. Or just change the filename in the readers. Sure beats the days I would have wasted on threads.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!