You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by johne <je...@yahoo.com> on 2008/01/23 07:19:06 UTC
Locking entire table
I am using the OJB 1.0.3 PB with MySql 5.0.
I have a series of processes that work off of a common table. This common
table is refreshed regularly. During this refresh, I would like to do to
the affect of:
1. Begin a transaction.
2. Lock the entire table.
3. Delete entire table.
4. Unlock entire table.
5. End transaction.
While a single process on a single server does this, it would be great if
the other read only processes seeking to use it were to fail fast with
exception.
Can anybody give me an example on how to do this?
So far I have to the affect of:
Query query = new QueryByCriteria(objectClass, null);
broker.beginTransaction();
broker.deleteByQuery(query);
broker.commitTransaction();
I am not sure how to do the fail fast table level locking. I feel I am
missing other things as well. I can use some help filling in the gaps. If
you have a better idea on how to implement, I am open. I was thinking I
could just put a locking record in another table, but thought this might be
better.
Thanks for any help.
JohnE
--
View this message in context: http://www.nabble.com/Locking-entire-table-tp15035646p15035646.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Locking entire table
Posted by johne <je...@yahoo.com>.
Armin,
Grats on your daughter! Mine is 14 now.
I trying to manage internationalization (UTF8) and a potential scaling
requirement for http://www.jobbank.com which has been using OJB for years.
To handle the scaling potential, I was considering either going vertical or
using distributed caching. I think I have decided to go with vertical for
now.
Always we have had temporary tables stored in memory. This is easy on one
server, but if we have to scale this will not work as is. In our new
approach, we are having a primary server handle long queries and place its
results into temporary tables. Secondary servers just utilize these
temporary smaller tables. When the primary server is refreshing, I don't
want the secondary servers to try to wait or update their local caches.
As time is progressing, I am thinking of just using a lock table to
represent states of each of these reads/updates, but I am not loving the
solution. Having such a method means you have to maintain the locks, which
is never a flavor I like. I am all done except for this locking issue.
John
--
View this message in context: http://www.nabble.com/Locking-entire-table-tp15035646p15114747.html
Sent from the Apache DB - ObjectRelationalBridge Users mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Locking entire table
Posted by Armin Waibel <ar...@apache.org>.
Hi JohnE,
johne wrote:
> I am using the OJB 1.0.3 PB with MySql 5.0.
>
> I have a series of processes that work off of a common table. This common
> table is refreshed regularly. During this refresh, I would like to do to
> the affect of:
> 1. Begin a transaction.
> 2. Lock the entire table.
> 3. Delete entire table.
> 4. Unlock entire table.
> 5. End transaction.
>
> While a single process on a single server does this, it would be great if
> the other read only processes seeking to use it were to fail fast with
> exception.
>
> Can anybody give me an example on how to do this?
>
> So far I have to the affect of:
> Query query = new QueryByCriteria(objectClass, null);
> broker.beginTransaction();
> broker.deleteByQuery(query);
> broker.commitTransaction();
>
> I am not sure how to do the fail fast table level locking.
I'm not sure that I get your point. Doesn't this depend on the database
isolation level? Or do you want to lock a database table by hand before
deleting all rows?
regards,
Armin
> I feel I am
> missing other things as well. I can use some help filling in the gaps. If
> you have a better idea on how to implement, I am open. I was thinking I
> could just put a locking record in another table, but thought this might be
> better.
>
> Thanks for any help.
>
> JohnE
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org