Skip to content

QueueTenancyBootstrapper Tenant Data Change Not Reflected #790

Closed
@mannis17

Description

@mannis17

Bug description

QueueTenancyBootstrapper will not recognize changes to Tenant Data until tenancy()->initialized is called.

  1. Tenant1 job arrives on the queue and is processed
  2. Tenant1 attribute data is updated.
  3. Tenant1 job arrives on the queue but since tenancy was already intialized the tenant data does not get updated for the currently initialized tenant

Looks to be the result of QueueTenancyBootstrapper::initializeTenancyForQueue code snippet (or setUpJobListener in 3.4.6)

  if (tenancy()->initialized) {
      if (tenant()->getTenantKey() === $tenantId) {
          // Tenancy is already initialized for the tenant (e.g. dispatchNow was used)
          return;
      }
  }

This prevents the tenancy initialization that occurs after this snippet.

Instead of return here what would be the implications of calling tenant()->end() ?

Unsure whether the If statement was only performance related. In the scenario above if Tenant2 job arrives and is processed prior to the 2nd Tenant1 job then when 2nd Tenant1 job is processed tenancy is intialized and correct attribute data is reflected.

Steps to reproduce

  1. Send job for Tenant1 to a queue
  2. Run Queue worker (and leave running) and output to log the data attribute you will change in point 3 below
  3. Edit Tenant1 data attribute
  4. Send job for Tenant1 to queue and output the data attirubte in point 3 below 3
  5. The old data attribute will appear

Expected behavior

  1. Send job for Tenant1 to a queue
  2. Run Queue worker (and leave running) and output to log the data attribute you will change in point 3 below
  3. Edit Tenant1 data attribute
  4. Send job for Tenant1 to queue and output the data attirubte in from point 3
  5. The new data attribute will appear

Laravel version

8

stancl/tenancy version

3.4.6 and 3.5.1

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions