-
Notifications
You must be signed in to change notification settings - Fork 618
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
why import do not return imported ids, when it called in sidekiq worker ? #793
Comments
If you can share the sql that is being executed in each scenario we may be able to help. Right now there isn't enough information. Is it the same model/table that you are importing into? You must be using Postgres? |
Actually facing a very similar issue. I have an import running in Sidekiq and no ids are being returned. This case scenarios is covered by specs, and the specs are passing (it does return ids). It just doesn't work when running in production/sidekiq. |
@jkowens I use MySQL. sql query with sidekiq worker result = ModelName.import array, validate: false
D, [2023-03-03T10:17:51.725232 #64421] DEBUG -- : ModelName Create Many (120.5ms) INSERT INTO `table_name` (`id`,`prefix`,....) VALUES (NULL,'[email protected]',.....),(NULL,'[email protected]',....),(NULL,'[email protected]',...)
#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1, ids=[], results=[]> sql with sidekiq worker result = ModelName.import array, validate: false
(0.6ms) BEGIN
(2.1ms) INSERT INTO `table_name` (`id`,`prefix`,...) VALUES (NULL,'[email protected]',...)
(1.3ms) INSERT INTO `table_name` (`id`,`prefix`,....) VALUES (NULL,'[email protected]',)
(3.2ms) INSERT INTO `table_name` (`id`,`prefix`,....) VALUES (NULL,'[email protected]',....)
(2.0ms) COMMIT
#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=3, ids=[412, 413, 414], results=[]> |
@Asdfif Returning ids is not supported for MySQL. Unlike Postgres, MySQL does not provide a way to return the ids of inserted rows. The example you show with the imported ids being populated doesn't seem right. Why did it produce 3 insert queries? |
@jkowens I did not understand yet why there are 3 queries. trying to figure it out |
If MySQL does not provide a way to return the ids of inserted why it returns ids when i use |
I use activerecord-import in Sidekiq worker and if I call worker by .perform_async then I get this result:
#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=1, ids=[], results=[]>
but if I call worker by .new.perform then I get this result:
#<struct ActiveRecord::Import::Result failed_instances=[], num_inserts=3, ids=[375, 376, 377], results=[]>
why?
The text was updated successfully, but these errors were encountered: