beyondcode / herd-community

82 stars 1 forks source link

[Bug]: Herd wiped my database #686

Closed cyppe closed 5 months ago

cyppe commented 5 months ago

Platform

macOS

Operating system version

14.4.1 (23E224)

System architecture

Intel (x86)

Herd Version

1.6.0

PHP Version

8.3.4

Bug description

I have a feeling this will be very hard to reproduce. But it has happened twice for me so something is going on.

Basically I am running Herd and everything is just fine. And the command I run has been run hundreds of times without debugging enabled without any issue.

And now I enabled debugging in phpstorm and started a artisan command that pushes jobs to queue.

And then there came this logs in laravel.log I have not seen before:

[2024-04-23 15:12:54] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/InitialRender.php on line 42  
[2024-04-23 15:12:54] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:54] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:54] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:54] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:58] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/InitialRender.php on line 42  
[2024-04-23 15:12:58] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:58] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:58] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  
[2024-04-23 15:12:58] local.WARNING: Creation of dynamic property Illuminate\Testing\TestResponse::$original is deprecated in /Users/thomasandersson/PhpstormProjects/generate.motoaction/vendor/livewire/livewire/src/Features/SupportTesting/SubsequentRender.php on line 56  

And then I was starting command a couple of minutes later, and now for some reason all tables in mysql is deleted and there is only a empty migrations table.

  1. I do not have any migrations at all in my project so it cannot have run some old migration by mistake
  2. The migrations table that was also created is empty so no trace of any migrations being run.
  3. Created at on migrations table is 15:12:58, so it matches the time when the errors in log above came.
  4. I do not have any tests in my project

Not sure what else I can share.

I wonder if the php code that is acting as some Herd proxy somehow can put Laravel into some state where it acts like if it's in some kind of test mode and wipes the database to prepare for test?

Otherwise no idea.

At least I am sure it's not my code / migrations that has any weird drop table logic.

Again - this feels like something hard to track down so I will just hope that the explaination maybe can trigger some idea from support team if there might be some fluke condition that can make it wipe database.

Lucky enough it's just a local test database so no harm done, more than being very annoying to recover it if it will happen often as my database is 100gb+.

Steps to reproduce

Not sure.

Relevant log output

Shared in description.
mpociot commented 5 months ago

Okay this is definitely a super weird error. Did the interaction with your app only happen via the CLI? I can't think if anything that would result in this behavior

cyppe commented 5 months ago

It was a CLI command, but I also had browser running a page with Livewire component with auto refresh so it also sent requests every second.

I will add logging for all queries that contains DROP TABLE and see if I can catch it if it happens again.

cyppe commented 5 months ago

I figured it out.

PHPStorm triggered Pest in some situations, and even if I had not configured Pest, it defaulted to my .env db connection and wiped database. So it had nothing to do with Herd.

Closing issue.

mpociot commented 5 months ago

Oh wow - that must've been quite tricky to debug! I'm glad that you figured it out!