Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecordVersionSynchroniseSlave doesn't work with blobs and PostgreSQL #147

Open
avavdoshin opened this issue Feb 27, 2023 · 10 comments
Open

Comments

@avavdoshin
Copy link

RecordVersionSynchroniseSlave doesn't synchronize tables with blob fields if SLAVE db is PostgreSQL (tested with mormot.db.sql.postgres).
It affect only with synchronisation. If i use PostgreSQL on master server, saving blobs works ok. Synchronisation works ok too if slave db is sqlite.

@synopse
Copy link
Owner

synopse commented Feb 27, 2023

Could you investigate a little and find out what actually happens?

@avavdoshin
Copy link
Author

Batch prepared correct, but something happened in BatchSend, i suppose, because i've got error when step-by-step debug "TSqlDBPostgresStatement.ExecutePrepared: Invalid array type ftBlob on bound parameter #3" (it is one of my blob fields) "in mormot.db.sql.postgres.pas line 656"

synopse pushed a commit that referenced this issue Feb 27, 2023
@synopse
Copy link
Owner

synopse commented Feb 27, 2023

Please try with this last commit.

@avavdoshin
Copy link
Author

It works now, but only if there is no deleted rows. If i have any deleted row - table doesn't synchronise at all.
Maybe it affected not only tables with blobs, i don't know. In my case i do not delete rows in another tables.

@synopse
Copy link
Owner

synopse commented Feb 28, 2023

I am not able to reproduce this behavior.

@avavdoshin
Copy link
Author

avavdoshin commented Feb 28, 2023

I create some orms on master
Then i created TOrm (1,2,3,4,5,6) with blob on master
Then delete record 4 with blob on master
then create some other orms on master

Then synchronise from master (sqlite) to slave (postgresql) (calling RecordVersionSynchroniseSlave from slave).
Nothing synchronised for TOrm (where i delete record), other orms synchronised well .

If i only create TOrm on master (do not delete) - synchronise works ok

@avavdoshin
Copy link
Author

In step-by-step debug i've got error
"Unexpected TSqlDBPostgresConnectionProperties.SharedTransaction (1,2)" in mormot.db.sql line 3701

Maybe it's because in prepared for sending batch i see in JSON that DELETE goes before all other lines? But this record cannot be deleted, it doesn't exist on slave server yet.

@avavdoshin
Copy link
Author

avavdoshin commented Mar 2, 2023

fails on TRestOrmServerBatchSend.AutomaticCommit after sequence POST-POST-POST-POST-DELETE-POST if ID for delete doesn't exists. Can't find out reason yet. No error message except "TSqlDBPostgresConnectionProperties.SharedTransaction( )"

upd: If i comment whole part for encDelete in TRestOrmServerBatchSend.ExecuteValue it fails too with the same exception

@synopse
Copy link
Owner

synopse commented May 9, 2023

Sorry for the late reaction.

What does "if ID for delete does not exist" mean in your case?

@avavdoshin
Copy link
Author

Sorry for the late reaction.

What does "if ID for delete does not exist" mean in your case?

I mean that record was deleted only on master db, it doesn't exist on slave db (sync was made after modifications on master db as i wrote before)
But when synchronization starts it tries to delete record which doesn't exist on slave db.
I suppose it's because of different transactions in post and delete chains

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants