You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lastID only contains valid information when the query was a successfully completed INSERT statement and changes only contains valid information when the query was a successfully completed UPDATE or DELETE statement. In all other cases, the content of these properties is inaccurate and should not be used. The .run() function is the only query method that sets these two values; all other query methods such as .all() or .get() don't retrieve these values.
After writing a demo to test, If we insert a conflicted entity after a successful insert. The lastID will be wrong, it will be the last insert statement's lastID.
And if we insert a conflicted entity without success inserting before, it will throw an error TypeORMError(Cannot update entity because entity id is not set in the entity.)
On the other hand, if send sudt at a full node, it will not affect the sync process, before inset into asset-account, it will insert a new item into indexer_tx_hash_cache at https://github.com/nervosnetwork/neuron/blob/v0.110.1/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts#L204.
// It will throw `TypeORMError(`Cannot update entity because entity id is not set in the entity.` when `tokenID` and // `blake160` exists.awaitconnection.createQueryBuilder().insert().into(AssetAccountEntity).values(assetAccount).onConflict(`("tokenID", "blake160") DO NOTHING`).execute()
// insert successawaitconnection.createQueryBuilder().insert().into(User).values(user).execute()// will run success even `tokenID` and `blake160` exists.awaitconnection.createQueryBuilder().insert().into(AssetAccountEntity).values(assetAccount).onConflict(`("tokenID", "blake160") DO NOTHING`).execute()
How to replay this bug
After Neuron sync to 100% with light client, restart Neuron to avoid the effect of other inserts. Send sudt from the asset accounts page, then we can find that sync will stop before the sudt transaction block number. We can recover it by clean cache because after clean cache there will exist many successful inserts.
How to fixed
We can set the asset account id as null when insert, it will not affect the insert result with generated grown id.
The text was updated successfully, but these errors were encountered:
What happened
When Neuron fetches a transaction with an ACP address, it will check and save the
sudt
token and ACP lock args to asset-account. But after we updatetypeorm
to 0.2.45, it will check whether the entity id has existed at https://github.com/typeorm/typeorm/blob/0.2.45/src/query-builder/ReturningResultsEntityUpdator.ts#L129. If we don't set entityId when saving an entity, the entity id query from https://github.com/typeorm/typeorm/blob/0.2.45/src/driver/sqlite/SqliteQueryRunner.ts#L74 and https://github.com/typeorm/typeorm/blob/0.2.45/src/driver/sqlite/SqliteQueryRunner.ts#L101 by https://github.com/TryGhost/node-sqlite3/wiki/API#runsql--param---callback, but the docs describelastID
thatAfter writing a demo to test, If we insert a conflicted entity after a successful insert. The
lastID
will be wrong, it will be the last insert statement'slastID
.And if we insert a conflicted entity without success inserting before, it will throw an error
TypeORMError(
Cannot update entity because entity id is not set in the entity.)
On the other hand, if send
sudt
at a full node, it will not affect the sync process, before inset into asset-account, it will insert a new item into indexer_tx_hash_cache at https://github.com/nervosnetwork/neuron/blob/v0.110.1/packages/neuron-wallet/src/block-sync-renderer/sync/indexer-cache-service.ts#L204.How to replay this bug
After Neuron sync to 100% with light client, restart Neuron to avoid the effect of other inserts. Send sudt from the asset accounts page, then we can find that sync will stop before the sudt transaction block number. We can recover it by clean cache because after clean cache there will exist many successful inserts.
How to fixed
We can set the asset account id as null when insert, it will not affect the insert result with generated grown id.
The text was updated successfully, but these errors were encountered: