# CSV imports fail - stalling In Progress, Runtime Less than 1 second

**URL:** <https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199>\
**Category:** Product Support\
**Tags:** mautic-4\
**Created:** [August 27, 2022, 4:11pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199 "2022-08-27T16:11:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [August 27, 2022, 4:11pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/1 "2022-08-27T16:11:53Z")

</div>

Trying to restart my business after a two year hiatus, I can’t get import of Contacts and Companies to work again - all worked fine two years ago.

Even with the most basic CSV file, importing in the background stalls with the following in Import History:

Status: In Progress  
Runtime: Less than 1 second  
Progress: 0%

I don’t know what this means; has anybody else seen this? Elsewhere I get this fail message:

```auto
Import failed. Reason: %reason%
View details of [TEST CONTACTS.csv (85)](https://mymauticpath/s/lead/import/view/85)

```

Using the Import in the Browser option, it just stalls on this:

```auto
#### Please do not leave this page until complete or queued.

#### Import is in progress.

```

The Details list also gives me no clues:

Status info: unknown

This in Details looks wrong to me:

`CSV parser config: delimiter = , , enclosure = \, escape = \\, batchlimit = 100`

Enclosure should be `"` instead of `\` I think - and in the UI it still does show `"`. Where is that CSV parser config set? **Edit:** A test.csv that avoided enclosures and escapes failed in the same, so this is probably not the cause.

In /var/logs the only thing I can find that may be relevant is this:

```auto
[2022-08-28 13:56:20] mautic.WARNING: File /home/myuser/public_html/mautic/app/../var/tmp/imports/20220828124859.csv was removed. [] {"hostname":"server.mysite.com","pid":31831}
[2022-08-28 13:14:01] mautic.WARNING: Command `mautic:import` exited with status code 1 [] {"hostname":"server.mysite.com","pid":880}

```

What else could I check or try? No idea how to troubleshoot this. I have already looked into cron jobs and think they’re OK.

**Your software**  
My Mautic version is: v4.4.1  
My PHP version is: 7.4.30  
My Database type and version is: 10.3.36-MariaDB

---

<div class="post-metadata">

**Author:** ![mikew](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mikew/32/5156_2.png) [@mikew](https://forum.mautic.org/u/mikew)\
**Post date:** [August 28, 2022, 4:09pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/2 "2022-08-28T16:09:43Z")

</div>

Hi there - I am shooting in the dark here, but are you sure the csv file is formatted UTF-8.

Also in order to trouble shoot maybe make a csv file with just one column called email, add one email and see what happens

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [August 28, 2022, 5:22pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/3 "2022-08-28T17:22:08Z")

</div>

@mikew, thanks, I appreciate the response, but yes, I am aware it has to be UTF-8 and have tested with stripped down files, including a one column file with only email.

I have just tested with a delete.csv list of bounced emails for a clean-up process that worked with no problems before 2020. I now got the same ‘Runtime Less Than 1 Second/0% Progress’ result with even that one.

Does anyone recognise this error? What else could I check? Maybe something in PHP configuration? What parts are involved in this import process that could break? I get nothing on google searches or in Mautic forum and see nothing in Mautic documentation etc. that applies.

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [August 29, 2022, 11:05am UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/4 "2022-08-29T11:05:38Z")

</div>

Should I look into PHP settings like these?:

max\_execution\_time This sets the maximum time in seconds a script is allowed to run before it is terminated by the parser. This helps prevent poorly written scripts from tying up the server. The default setting is 30.   
PHP Default: 30

max\_input\_time This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads.   
PHP Default: -1

max\_input\_time is set at 60 while the recommended default is -1. After changing that to -1, I get the following in Import History:

```auto
In Progress	
 DELETE.csv
Runtime: 18 hours 21 minutes	
Progress: 0%

```

Not sure if that is an improvement… When I then reimport the same delete.csv file, with just one column bounced email addresses, I get the same ‘In Progress/Less than 1 second/0%’ stalled result.

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [August 29, 2022, 3:31pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/5 "2022-08-29T15:31:13Z")

</div>

When I upload a fresh delete.csv file - one column of bounced emails for a clean-up process - and then try to mautic:import via SSH as ‘username’ (not root), I get the following error message:

```auto
Import 92 with 45 rows is starting.
  0/45 [>---------------------------] 0%
In AbstractMySQLDriver.php line 68:

  An exception occurred while executing 'INSERT INTO lead_event_log (user
  _id, user_name, bundle, object, action, object_id, date_added, properties,
  lead_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [1, "My Name", "lead", "import", "updated", 92, "2022-08-29 15:39:05", "{\"line\":3,
  \"file\":\"DELETE.csv\"}", "9670"]:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update
  a child row: a foreign key constraint fails (`username_mautic`.`lead_event_log`, CONSTRAINT `FK_78B7E97955458D` FOREIGN KEY (`lead_id`) REFERENCES
   `leads` (`id`) ON DELETE CASCADE)

In Exception.php line 18:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update
  a child row: a foreign key constraint fails (`username_mautic`.`lead_event_log`, CONSTRAINT `FK_78B7E97955458D` FOREIGN KEY (`lead_id`) REFERENCES
   `leads` (`id`) ON DELETE CASCADE)

In PDOStatement.php line 117:

  SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update
  a child row: a foreign key constraint fails (`username_mautic`.`lead_event_log`, CONSTRAINT `FK_78B7E97955458D` FOREIGN KEY (`lead_id`) REFERENCES
   `leads` (`id`) ON DELETE CASCADE)

mautic:import [-i|--id [ID]] [-l|--limit [LIMIT]] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-e|--env ENV] [--no-debug] [--] <command>

```

I’ve run into ‘foreign key constraint fails’ in other places, probably the same issue. Does anyone know what this relates to?

What is FK\_78B7E97955458D?  
What is the role of lead\_event\_log in importing contacts data via csv?  
Is there a way to reset that table or whatever is causing these hang-ups?  
What is involved in the import process; what should I check?  
What does `VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)` mean - looks bad…?  
How can I solve [‘an integrity violation that seems to point to a foreign key that does not exist in the database’](https://forum.mautic.org/t/integrity-constraint-violation/16731/2)?

I’m at a dead end here. Any suggestions or best guesses how to troubleshoot this would be very much appreciated.

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 2, 2022, 5:49pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/6 "2022-09-02T17:49:20Z")

</div>

[In this case](https://forum.mautic.org/t/4-2-cant-send-email-error-500-foreign-key-constraint-fails/22933/9) a failing foreign key constraint was apparently caused by an encoding mismatch. Almost all of the tables in my database had collation utf8\_unicode\_ci. A few had utf8mb4\_unicode\_ci; I have converted those to utf8\_unicode\_ci and will test later if that made any difference…

What else could I check? Is there a way to safely “reset” the tables that cause these problems? Or does the ‘integrity constraint violation’ point to another problem - what problem does it point to?

**Edit:**

I am now converting all tables to utf8mb4\_unicode\_ci, [following this recipe to fix the general foreign key mess](https://github.com/mautic/mautic/issues/9129).

Using `alter table lead_event_log CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;`, I get the following unusual error:

> #1025 - Error on rename of ‘./mydatabase/#sql-a26\_721a’ to ‘./mydatabase/lead\_event\_log’ (errno: 150 “Foreign key constraint is incorrectly formed”)

Same error on tables oauth2\_accesstokens, oauth2\_clients, oauth2\_refreshtokens, users, …

Several other tables, like plugin\_citrix\_events, have this error:

> Specified key was too long; max key length is 3072 bytes

Does anyone know what this means?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 10, 2022, 1:42pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/7 "2022-09-10T13:42:09Z")

</div>

Back to this thread after a [fruitless tangent here](https://forum.mautic.org/t/errors-after-running-schema-update-foreign-key-constraint/25286/10), trying to fix what I thought might be the core foreign key problem…

[This still looks most promising for next things to try](https://github.com/mautic/mautic/issues/9129#issuecomment-707708797), with [additional clue here](https://github.com/mautic/mautic/issues/9129#issuecomment-812061248) and [this here](https://github.com/mautic/mautic/issues/9129#issuecomment-695751262). However this solution [failed here](https://github.com/mautic/mautic/issues/9129#issuecomment-812566478) and here [explained why it fails](https://github.com/mautic/mautic/issues/9129#issuecomment-1044958793).

Were fixes implemented in latest updates? I’ll try to update to 4.4.2 to see if that fixes the csv import issue.

**Next day:**

Starting the 4.4.2 upgrade process I found the suggestion to run `php bin/console doctrine:schema:validate`. This gives me the following message:

## `Mapping

[FAIL] The entity-class Mautic\DynamicContentBundle\Entity\DynamicContentLeadData mapping is invalid:

- The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which is not defined as association.
- The association Mautic\DynamicContentBundle\Entity\DynamicContentLeadData#dynamicContent refers to the inverse side field Mautic\DynamicContentBundle\Entity\DynamicContent#id which does not exist.

## Database

[ERROR] The database schema is not in sync with the current mapping file.  
`

This was [raised as an issue here](https://github.com/mautic/mautic/issues/10864) and is apparently [also connected with the foreign key issue](https://github.com/mautic/mautic/issues/10865) from my [fruitless tangent here](https://forum.mautic.org/t/errors-after-running-schema-update-foreign-key-constraint/25286/10). What is the current status of this @escopecz @aerendir @DonGilbert @silavapi ?

I don’t see a solution in that thread, but it has been closed as ‘stale’ - I’ll start googling and researching ‘unidirectional vs bidirectional association’ now, but am unlikely to come up with a solution for this on my own.

[There is another thread on this without solution here.](https://forum.mautic.org/t/cant-load-configuration-page-after-trying-to-add-an-imap-account/19131/3)

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 14, 2022, 11:57am UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/8 "2022-09-14T11:57:24Z")

</div>

I’ve been [advised here](https://forum.mautic.org/t/errors-after-running-schema-update-foreign-key-constraint/25286/17) that I can ignore the schema error for now, so I’ll try to do the upgrade to 4.4.2 in the next hours… Or bad idea? Anything else I should do/check?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [September 18, 2022, 7:08pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/9 "2022-09-18T19:08:43Z")

</div>

Upgrading to 4.4.2 did not fix anything. I still have the same error. I’ll continue to bang my head against the wall about this next weekend. Any troubleshooting ideas or solutions or clues very much appreciated.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 3, 2022, 2:37pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/10 "2022-10-03T14:37:18Z")

</div>

> [@modifiedcontent](#):
>
> `username_mautic`

Hi, what is this field?

username\_mautic

?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 8, 2022, 12:45pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/11 "2022-10-08T12:45:10Z")

</div>

@joeyk - thanks for the follow-up. I think I got the Mautic app administrator username there and also my own full name earlier in the error message - I am the only admin on the system.

I still get the same ‘Less than 1 second - 0%’ error after updating to 4.4.3.

According to mysqlcheck all database tables are OK, so I doubt rebuilding the database would fix anything.

???

Still completely stuck. What else could I check/try? Is there anyone who udnerstands the inner working of the code what would trigger these particular error messages - ‘less than 1 second’ etc.?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 10, 2022, 8:16am UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/12 "2022-10-10T08:16:11Z")

</div>

How can I replicate all the step in this CSV import process manually, to find out where it breaks?

I had already asked how to [manually import contacts here](https://forum.mautic.org/t/is-there-a-clean-way-to-manually-import-contacts-etc-via-phpmyadmin/25435/5) and the last answer was essentially that it can’t be done (?).

It should be possible to just go manually through the steps of this failing CSV import process. What database queries are involved? Is there a way to find out, generate a list of SQL to go through?

Which scripts, files, functions are involved?

Etc.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 10, 2022, 8:49am UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/13 "2022-10-10T08:49:22Z")

</div>

Can you PM me an example of your CSV (just plz leave 1 line in there, so I can test.) I really want to see that migic csv that kills your instance 😃

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 15, 2022, 7:13pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/14 "2022-10-15T19:13:22Z")

</div>

[After another diversion](https://forum.mautic.org/t/rebuild-database-without-reinstalling-everything/25565/19) I now want to try to “fix” or “restore” the `lead_event_log` table with whatever solution I can find. I thought I could use `mysqlcheck r- ...`, but [this site says mysqlcheck only works for MyISAM tables](https://www.stellarinfo.com/blog/repair-mysql-tables-using-mysqlcheck/), not InnoDB.

Is that correct or is [stellarinfo.com](http://stellarinfo.com) just trying to sell their software? What are my alternative options?

I can access ‘the MariaDB monitor’ via SSH, by simply typing `mysql` and enter, but logged in as root. Can I manage MySQL as root or will that cause all kinds of file permission and ownership problems again? Should I log in as some kind of user? With a user/pass for a specific database? How would I access a specific database?

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 16, 2022, 2:19pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/15 "2022-10-16T14:19:13Z")

</div>

What is the role of [lead\_event\_log](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/5) in importing via CSV?

I tried to change collation of that table to utf8mb4\_general\_ci via PHPMyAdmin, but get a ‘foreign key contraint incorrectly formed’ error message.

When I try to downgrade (?) that table from InnoDB to MYISAM I get this error message:

```auto
Error
Static analysis:

1 errors were found during analysis.

Missing comma before start of a new alter operation. (near "DEFAULT CHARSET" at position 51)
SQL query: Edit Edit

ALTER TABLE `mtc_lead_event_log` ENGINE = MYISAM DEFAULT CHARSET=utf8 COLLATE utf8_unicode_ci;

MySQL said: Documentation

#1071 - Specified key was too long; max key length is 1000 bytes

```

I tried ‘Optimize table’ in PHPMyAdmin, which returned this unhelpful message:

```auto
username_mautic.lead_event_log	optimize	note	Table does not support optimize, doing recreate + ...
username_mautic.lead_event_log	optimize	status	OK

```

‘… recreate + …’ is apparently [‘… recreate + analyze instead’](https://stackoverflow.com/questions/30635603/what-does-table-does-not-support-optimize-doing-recreate-analyze-instead-me).

And lo and behold, after two months without any useful help/hints from Mautic developers, it actually seems to have fixed my problem; import of the most basic CSV now results in ‘Runtime 2 seconds, Progress 100%, 2 inserted, 43 updated’.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 17, 2022, 8:24am UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/16 "2022-10-17T08:24:59Z")

</div>

I’m glad you fixed it.  
I saw this error during upgrades from 2.16, but it didn’t come to my mind, that you should check DB collation, I’m sorry.

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [October 30, 2022, 10:48pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/17 "2022-10-30T22:48:59Z")

</div>

It’s not fixed. It’s still/again (?) failing with the same errors.

**Edit:** After ‘Optimize table’ on the same lead\_event\_log via PHPMyAdmin again, the import that kept failing went through.

---

<div class="post-metadata">

**Author:** ![ezzat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ezzat/32/825_2.png) [@ezzat](https://forum.mautic.org/u/ezzat)\
**Post date:** [November 7, 2022, 4:57pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/18 "2022-11-07T16:57:21Z")

</div>

I’m currently experiencing the same issue but while trying to update segments through the CLI and I see the error all over the log from the cron job to update segments,

Optimizing lead\_event\_log in phpmyadmin did not work for me unfortunately

---

<div class="post-metadata">

**Author:** ![modifiedcontent](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/modifiedcontent/32/511_2.png) [@modifiedcontent](https://forum.mautic.org/u/modifiedcontent)\
**Post date:** [November 7, 2022, 5:17pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/19 "2022-11-07T17:17:50Z")

</div>

Are there other tables involved you could try to optimize/fix?

Ultimately the foreign key errors seemed to have something to do with collation; I think you’re supposed to utf8mb4\_unicode\_ci instead of utf8\_unicode\_ci. Nobody knows.

---

<div class="post-metadata">

**Author:** ![ezzat](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ezzat/32/825_2.png) [@ezzat](https://forum.mautic.org/u/ezzat)\
**Post date:** [November 7, 2022, 5:31pm UTC](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199/20 "2022-11-07T17:31:44Z")

</div>

The error seems to be exclusive to that table according to the errors in the image  
Is there a way I can track the specific row with that key and just delete it?

[[Album] imgur.com ![](https://us1.discourse-cdn.com/flex020/uploads/mautic/original/2X/3/3e32959015f33161711a2e7358e0a7857b7355b9.jpeg "imgur.com") ](https://imgur.com/a/8zztjc9)

coalition of this table is utf8\_unicode\_ci ☹

[Next page](https://forum.mautic.org/t/csv-imports-fail-stalling-in-progress-runtime-less-than-1-second/25199.md?page=2)
