[Db] contatore server side
Marcello Vezzelli
marcello a vezz.it
Gio 1 Feb 2007 12:04:33 CET
Domenico L. wrote:
>
> Con gli innodb, dovresti richiedere un lock di tipo write su tutta la
> tabella (non so la sintassi purtroppo, ma dovrebbe riguardare
> l'isolation level), in questo modo tutti possono leggere ma solo tu
> scrivi, il problema è che blocchi anche gli update.
Dovrebbe essere qualcosa del tipo
LOCK TABLES fatture WRITE;
...
UNLOCK TABLES;
Solo che c'è il problema dell'autocommit...
http://dev.mysql.com/doc/refman/5.1/en/lock-tables.html
The correct way to use |LOCK TABLES| with transactional tables, such as
|InnoDB| tables, is to set |AUTOCOMMIT = 0| and not to call |UNLOCK
TABLES| until you commit the transaction explicitly. When you call |LOCK
TABLES|, |InnoDB| internally takes its own table lock, and MySQL takes
its own table lock. |InnoDB| releases its table lock at the next commit,
but for MySQL to release its table lock, you have to call |UNLOCK
TABLES|. You should not have |AUTOCOMMIT = 1|, because then |InnoDB|
releases its table lock immediately after the call of |LOCK TABLES|, and
deadlocks can very easily happen. Note that we do not acquire the
|InnoDB| table lock at all if |AUTOCOMMIT=1|, to help old applications
avoid unnecessary deadlocks.
Certo che cmq è un delirio dover impazzire per una cosa relativamente
facile.
In questo caso la tabella "fatture" potrebbe anche essere myIsam che non
succede niente... però se uno avesse veramente bisogno di questo
meccanismo su una tabella InnoDb c'è da tribolare non poco. Troppe
restrizioni o giravolte da fare.
Saluti
Marcello
Maggiori informazioni sulla lista
Db