codeigniter - Unexpected AUTO_INCREMENT behaviour -
we have server running php 5.6.7, mariadb 10.0.17-mariadb. have codeigniter application, in have 2 tables: point_trigger
, trigger_filter
, connected point_trigger_id
, one-to-many. both have id
column set integer auto_increment
(so no composite keys). heppened:
a client removed 1 of
point_trigger
s web interface. sa called controller removed rowpoint_trigger
, row (just 1 in case)trigger_filter
. call logged, ends/delete/235
, meaningpoint_trigger_id
used locate rows deleted set235
. far good.couple of days later client goes web interface again , adds new
point_trigger
.client calls because point trigger created behaves unexpectedly.
we check database, and...
point_trigger
table not have gap in ids, meaningpoint_trigger
user created has the same id235
. check associatedtrigger_filter
table , 1 doesn't have gap, autoincremented id table next one.
what know (or think know) both delete , add went ok in terms of removing rows. think because point_trigger
client created after removing previous 1 has different parameters, , no edits logged before delete , add.
so apperantly there made auto_increment recalculate in time between delete , add of point_trigger
. can tell or point be?
thanks in advance!
that user created has same id 235
could sequence of events?
- insert row , 235 assigned
- delete 235, leaving max(id)=234
- shut down mariadb
- start mariadb
- insert row , 235 again.
to elaborate on step 5:
- open table -- find max(id)+1 (234+1) next id assign
auto_increment
- insert gets value (235).
sorry, way works. auto_increment
guarantees uniqueness @ moment in time, not on time.
Comments
Post a Comment