Skip to content

Commit 087f50c

Browse files
authored
Prevent landlord connection purge in BulkImportProcessor
Add check to avoid purging landlord connection in multi-tenant setups.
1 parent 8e1f223 commit 087f50c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/Import/Jobs/BulkImportProcessor.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,13 @@ public function handle(): void
106106
// This is critical in multi-tenant environments where DB::purge() may have been called
107107
// during tenant switching, causing the Connection object in DatabaseBatchRepository
108108
// to have a null PDO. This fix is safe for non-multi-tenant apps as well.
109+
//
110+
// IMPORTANT: Do NOT purge the landlord connection as it can lose its database
111+
// configuration in multi-tenant setups. The landlord connection should remain stable.
109112
$batchConnection = config('queue.batching.database');
113+
$landlordConnection = config('multitenancy.landlord_database_connection_name', 'landlord');
110114

111-
if ($batchConnection) {
115+
if ($batchConnection && $batchConnection !== $landlordConnection) {
112116
// Purge and reconnect to ensure clean connection state
113117
DB::purge($batchConnection);
114118

0 commit comments

Comments
 (0)