postUpdate's not persisted

Hi there,

Im not sure if this is a openhab2, openhab issue or no issue at all, but Im encountering a strange behavior. Sometimes I use the postUpdate method to “fake” some values in the timeline of an Item. So for example:

myItem.sendCommand(18);
myItem.postUpdate(16);
myItem.postUpdate(4);

logInfo('Whats the previous value of myItem? ', myItem.previousState().state); // logs 18  

I use postUpdate to not trigger any binding action. Is this expected behavior or am I doing something wrong?

Facts:
I use some of the latest snapshot builds of openhab2 on a RPI2 with mysql as persistent backend.
mysql.persist:

Items {
    * : strategy = everyChange, everyUpdate
}

Thanks!

You have a typo in

myItem.postUpate(4);

Nonetheless, I would expect it to log “16” in this case.
Do you have any logs from the persistence service?

Fixed typo.

There is no output from the persistence service. Event log says myItem changed from 18 to 16 and from 16 to 4. Thats it :confused:

Should I enable debug mode for the mysql service?

Btw: 16 is also my expected result

Yes, this should tell you what values are persisted by the persistence layer.

Mh thats very strange. If I do:

myItem.sendCommand(18);
myItem.postUpdate(16);
myItem.postUpdate(4);

I get:

2016-10-08 10:53:27.060 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: Stored item 'myItem' as '18'[18] in SQL database at 2016-10-08 10:53:27.061.
2016-10-08 10:53:27.061 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item252 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;
2016-10-08 10:53:27.157 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: Stored item 'myItem' as '16'[16] in SQL database at 2016-10-08 10:53:27.149.
2016-10-08 10:53:27.160 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item252 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;
2016-10-08 10:53:27.169 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: Stored item 'myItem' as '4'[4] in SQL database at 2016-10-08 10:53:27.167.
2016-10-08 10:53:27.172 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item252 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;
2016-10-08 10:53:27.181 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: Stored item 'myItem' as '4'[4] in SQL database at 2016-10-08 10:53:27.178.
2016-10-08 10:53:27.182 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item252 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;
2016-10-08 10:53:27.191 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: Stored item 'myItem' as '4'[4] in SQL database at 2016-10-08 10:53:27.188.
2016-10-08 10:53:27.193 [DEBUG] [sql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item252 (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;

Why 4 is inserted three times?
But nonetheless it should log 16 as myItem.previousState(true).state and not 18!?