chrisan

Member Since 1 Year Ago

Experience Points
6,390
Total
Experience

3,610 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed
52
Lessons
Completed
Best Reply Awards
0
Best Reply
Awards
  • start your engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-in-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • evangelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

  • Community Pillar

    Earned once your experience points ranks in the top 10 of all Laracasts users.

Level 2
6,390 XP
May
04
2 weeks ago
Activity icon

Replied to With GDPR Is Everyone Encrypting Names And Emails?

I’m curious about how you might get access to a database without getting it via the application.

A backup copy in an unsecured place, direct database access if you don't lock things down. Or in the case where you have an employee (or yourself) with a compromised computer, they likely have access to backups or direct database access or even a development copy to debug with locally.

I am definitely no hacker to think up all the ways an attack could happen, and in our case we are just a B2B app, so "who cares" if the world knows some business has an account with us, but alas there is always that checkbox for "encrypted pii data at rest" when signing vendor agreements. So far that hasn't prevented us from signing a new company, but my boss would like to check that box lol

May
03
2 weeks ago
Activity icon

Started a new Conversation With GDPR Is Everyone Encrypting Names And Emails?

Eloquent mutator/accessor or something like https://github.com/betterapp/laravel-db-encrypter ?

Apr
13
1 month ago
Activity icon

Awarded Best Reply on Possible To Have Custom 404 For API?

Looks like you need to handle it in Handler.php

  /**
   * Render an exception into an HTTP response.
   *
   * @param \Illuminate\Http\Request $request
   * @param \Exception $exception
   * @return \Symfony\Component\HttpFoundation\Response
   *
   * @throws \Exception
   */
  public function render($request, Exception $exception) {
    if (strpos($request->getRequestUri(), '/api/', 0) === 0 &&
      get_class($exception) === NotFoundHttpException::class) {
        return response()->json(['message' => 'Not found'], 404);
    }

    return parent::render($request, $exception);
  }
Activity icon

Replied to Possible To Have Custom 404 For API?

Looks like you need to handle it in Handler.php

  /**
   * Render an exception into an HTTP response.
   *
   * @param \Illuminate\Http\Request $request
   * @param \Exception $exception
   * @return \Symfony\Component\HttpFoundation\Response
   *
   * @throws \Exception
   */
  public function render($request, Exception $exception) {
    if (strpos($request->getRequestUri(), '/api/', 0) === 0 &&
      get_class($exception) === NotFoundHttpException::class) {
        return response()->json(['message' => 'Not found'], 404);
    }

    return parent::render($request, $exception);
  }
Activity icon

Replied to Possible To Have Custom 404 For API?

OK, no not anything else unless I'm miss understanding something

composer create-project laravel/laravel example-app

Then edit api.php

<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
Route::middleware('api')->get('/foo', function(Request $request) {
    return [];
});

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

visit http://localhost:8000/api/foo and we see a json empty array

however visit http://localhost:8000/api/bar and we get a HTML 404

And to be clear, I'm specifically looking for this formatting on 404s of bogus/not defined routes

Activity icon

Replied to Possible To Have Custom 404 For API?

404 on an API page : json response with 404 HTTP code

Hmm, then perhaps I have something else wrong as the API routes return a HTML 404 response instead of a JSON one

Activity icon

Started a new Conversation Possible To Have Custom 404 For API?

Using Route::domain('api.example.com') for API routes, how could one setup something where you get a different 404 for all API requests

https://api.github.com/emojis and https://api.github.com/emogees

vs

https://github.com/featuers and https://github.com/features

Mar
17
2 months ago
Activity icon

Replied to [6.x] How Do You Use A Closure Validator?

Thanks for the reply and that got me halfway there, or at least pointed in right direction. I still wasn't sure how you get the nice form validation after checking if it failed

Further up in the documentation it said to call ->validate()

So I guess you have to do the normal $request->validate(...) then call validate() on the closure based one. This way it handles the redirection and form error population

Activity icon

Started a new Conversation [6.x] How Do You Use A Closure Validator?

https://laravel.com/docs/6.x/validation#custom-validation-rules

$validator = Validator::make($request->all(), [
    'title' => [
        'required',
        'max:255',
        function ($attribute, $value, $fail) {
            if ($value === 'foo') {
                $fail($attribute.' is invalid.');
            }
        },
    ],
]);

What comes next?

I tried $request->validate(['my_title_field' => ['title']]);

and get

BadMethodCallException Method Illuminate\Validation\Validator::validateTitle does not exist.

also $request->validate(['my_title_field' => [$validator]]);

Symfony\Component\Debug\Exception\FatalThrowableError Object of class Illuminate\Validation\Validator could not be converted to string

Mar
13
2 months ago
Activity icon

Awarded Best Reply on Laravel 6 Kernel Scheduler Creating Duplicate Jobs

no errors, other than the laravel MaxAttemptsExceededException tries are already 1.

Looks like the root cause is in queue.php the retry_after has to match the --timeout value. The default was 90 and looking back at the worker log it would attempt those jobs about 90 seconds later. The other jobs didnt get repeated because they ran in under 90 seconds.

Not sure what the point of --timeout is if the queue retries the job anyways ignoring that value.

it's been about 10minutes since my last attempt an no errors yet now that retry_after matches timeout

Activity icon

Replied to Laravel 6 Kernel Scheduler Creating Duplicate Jobs

no errors, other than the laravel MaxAttemptsExceededException tries are already 1.

Looks like the root cause is in queue.php the retry_after has to match the --timeout value. The default was 90 and looking back at the worker log it would attempt those jobs about 90 seconds later. The other jobs didnt get repeated because they ran in under 90 seconds.

Not sure what the point of --timeout is if the queue retries the job anyways ignoring that value.

it's been about 10minutes since my last attempt an no errors yet now that retry_after matches timeout

Mar
12
2 months ago
Activity icon

Replied to Laravel 6 Kernel Scheduler Creating Duplicate Jobs

I switched to redis and same issue with duplicate jobs such as gO7YWftHnrLetyiU2Ajg9P6rXFBbbYlJ

[2021-03-13 00:30:04][kTHA75lBOeKEOCbGbV6QnfC3rCWz4QgM] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][qcbaA4CB6MXpBHYw9exp6buxXxq5O5RN] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][kTHA75lBOeKEOCbGbV6QnfC3rCWz4QgM] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][F9FLnL6q0jI2d5GDdHOCOs63mUtrdSKu] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][Kkv917W9Cf8wjQJy1hSqocfzKvlGiPub] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][D4LmK80JUIAlO7C1ucCuRUw06Qq8GFr6] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][F9FLnL6q0jI2d5GDdHOCOs63mUtrdSKu] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][EiMfVu3Ku5VywzlbRmMZDc0eTxMFwgJP] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][EiMfVu3Ku5VywzlbRmMZDc0eTxMFwgJP] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][Nodz2dmKprvDJpo1tRPCTpUlVCT7rtHi] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][Nodz2dmKprvDJpo1tRPCTpUlVCT7rtHi] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][je06cHyLc6Af3QtsKPfYCBclYRmqo8cx] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][je06cHyLc6Af3QtsKPfYCBclYRmqo8cx] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][qcbaA4CB6MXpBHYw9exp6buxXxq5O5RN] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][nduFPKWYulYPFRawcXwshDX4pIH6vgCF] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][KyyhkT1tdmMYUdwde0SKOprdSbLw2YkN] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][D4LmK80JUIAlO7C1ucCuRUw06Qq8GFr6] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][N4tMEljyAMgYSpRGLIw927P3j0C78RDp] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][nduFPKWYulYPFRawcXwshDX4pIH6vgCF] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][NN84lpPKOd8dHzPrFlzcrMb4AeV2f9TH] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][KyyhkT1tdmMYUdwde0SKOprdSbLw2YkN] Processed:  App\Jobs\RunImport  
[2021-03-13 00:30:04][Kkv917W9Cf8wjQJy1hSqocfzKvlGiPub] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][Z2OIkFAng7ALdhFAxcBXRLfuYDHHLVwE] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][7Jif2MhYbWARtvnGFZkOsoQu81kNo2Ik] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][N4tMEljyAMgYSpRGLIw927P3j0C78RDp] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][GSaHOMbdtIQaWuXm0m9COKqWhB7Beb7s] Processing: App\Jobs\RunImport
[2021-03-13 00:30:04][Z2OIkFAng7ALdhFAxcBXRLfuYDHHLVwE] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][NN84lpPKOd8dHzPrFlzcrMb4AeV2f9TH] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][7Jif2MhYbWARtvnGFZkOsoQu81kNo2Ik] Processed:  App\Jobs\RunImport
[2021-03-13 00:30:04][GSaHOMbdtIQaWuXm0m9COKqWhB7Beb7s] Processed:  App\Jobs\RunImport
[2021-03-13 00:40:04][c2L6HFeGzAUHu5ZjafJht0HJus8890Yl] Processing: App\Jobs\RunImport
[2021-03-13 00:40:04][mKbkQGq6bDKHZKKEMjyJJmegOowCBYB3] Processing: App\Jobs\RunImport
[2021-03-13 00:40:04][7YRHYi2Ma1EVc9e7aKHzaqNnfcvOKQSm] Processing: App\Jobs\RunImport
[2021-03-13 00:40:04][FeVVJ9efoBHQYXzy1IDCwaOVtgRaqZZz] Processing: App\Jobs\RunImport
[2021-03-13 00:46:04][c2L6HFeGzAUHu5ZjafJht0HJus8890Yl] Processed:  App\Jobs\RunImport
[2021-03-13 00:46:04][3KtnJTGtuGxf8CZySazDKy8dnyjnoVQv] Processing: App\Jobs\RunImport
[2021-03-13 00:46:04][mKbkQGq6bDKHZKKEMjyJJmegOowCBYB3] Processed:  App\Jobs\RunImport
[2021-03-13 00:46:04][e4GZaccvLx8LMXL4YQgcW3KHtIMl68dn] Processing: App\Jobs\RunImport
[2021-03-13 00:46:04][7YRHYi2Ma1EVc9e7aKHzaqNnfcvOKQSm] Processed:  App\Jobs\RunImport
[2021-03-13 00:46:04][2xtHcvrAnfOfre5PIfhje732RYC1Al7R] Processing: App\Jobs\RunImport
[2021-03-13 00:46:04][FeVVJ9efoBHQYXzy1IDCwaOVtgRaqZZz] Processed:  App\Jobs\RunImport
[2021-03-13 00:46:04][I6Op9TvjwTp18Le4TuSn9fVhQ0almiIs] Processing: App\Jobs\RunImport
[2021-03-13 00:52:04][3KtnJTGtuGxf8CZySazDKy8dnyjnoVQv] Processed:  App\Jobs\RunImport
[2021-03-13 00:52:04][BuA4C2lRzVKRyXLEiv0ctsTx04IlVOzy] Processing: App\Jobs\RunImport
[2021-03-13 00:52:04][e4GZaccvLx8LMXL4YQgcW3KHtIMl68dn] Processed:  App\Jobs\RunImport
[2021-03-13 00:52:04][lfWXhuqgtOX1ffIPYhhYp4H11Q6PeMBO] Processing: App\Jobs\RunImport
[2021-03-13 00:52:04][2xtHcvrAnfOfre5PIfhje732RYC1Al7R] Processed:  App\Jobs\RunImport
[2021-03-13 00:52:04][kS5vOtWTAtqBuuAP5kItGyvAcBRCUuEH] Processing: App\Jobs\RunImport
[2021-03-13 00:52:04][I6Op9TvjwTp18Le4TuSn9fVhQ0almiIs] Processed:  App\Jobs\RunImport
[2021-03-13 00:52:04][BlsOtcDvSgKvTIAsX8AEGTLWCK4jXgkh] Processing: App\Jobs\RunImport
[2021-03-13 00:58:04][BuA4C2lRzVKRyXLEiv0ctsTx04IlVOzy] Processed:  App\Jobs\RunImport
[2021-03-13 00:58:04][BEAkgmSla6hCiATtfC71yUu1M9Hvfhj8] Processing: App\Jobs\RunImport
[2021-03-13 00:58:04][lfWXhuqgtOX1ffIPYhhYp4H11Q6PeMBO] Processed:  App\Jobs\RunImport
[2021-03-13 00:58:04][PPT6mqKuvCPUSpSIeBRrvWtbeBfrpxP9] Processing: App\Jobs\RunImport
[2021-03-13 00:58:04][BlsOtcDvSgKvTIAsX8AEGTLWCK4jXgkh] Processed:  App\Jobs\RunImport
[2021-03-13 00:58:04][kS5vOtWTAtqBuuAP5kItGyvAcBRCUuEH] Processed:  App\Jobs\RunImport
[2021-03-13 00:58:04][gO7YWftHnrLetyiU2Ajg9P6rXFBbbYlJ] Processing: App\Jobs\RunImport
[2021-03-13 00:58:04][7YRHYi2Ma1EVc9e7aKHzaqNnfcvOKQSm] Processing: App\Jobs\RunImport
[2021-03-13 00:58:04][7YRHYi2Ma1EVc9e7aKHzaqNnfcvOKQSm] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:04][FeVVJ9efoBHQYXzy1IDCwaOVtgRaqZZz] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][FeVVJ9efoBHQYXzy1IDCwaOVtgRaqZZz] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][mKbkQGq6bDKHZKKEMjyJJmegOowCBYB3] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][mKbkQGq6bDKHZKKEMjyJJmegOowCBYB3] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][2xtHcvrAnfOfre5PIfhje732RYC1Al7R] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][2xtHcvrAnfOfre5PIfhje732RYC1Al7R] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][I6Op9TvjwTp18Le4TuSn9fVhQ0almiIs] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][I6Op9TvjwTp18Le4TuSn9fVhQ0almiIs] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][e4GZaccvLx8LMXL4YQgcW3KHtIMl68dn] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][e4GZaccvLx8LMXL4YQgcW3KHtIMl68dn] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][BlsOtcDvSgKvTIAsX8AEGTLWCK4jXgkh] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][BlsOtcDvSgKvTIAsX8AEGTLWCK4jXgkh] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][kS5vOtWTAtqBuuAP5kItGyvAcBRCUuEH] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][kS5vOtWTAtqBuuAP5kItGyvAcBRCUuEH] Failed:     App\Jobs\RunImport
[2021-03-13 00:58:05][lfWXhuqgtOX1ffIPYhhYp4H11Q6PeMBO] Processing: App\Jobs\RunImport
[2021-03-13 00:58:05][lfWXhuqgtOX1ffIPYhhYp4H11Q6PeMBO] Failed:     App\Jobs\RunImport
[2021-03-13 00:59:36][BEAkgmSla6hCiATtfC71yUu1M9Hvfhj8] Processing: App\Jobs\RunImport
[2021-03-13 00:59:36][BEAkgmSla6hCiATtfC71yUu1M9Hvfhj8] Failed:     App\Jobs\RunImport
[2021-03-13 00:59:36][PPT6mqKuvCPUSpSIeBRrvWtbeBfrpxP9] Processing: App\Jobs\RunImport
[2021-03-13 00:59:36][PPT6mqKuvCPUSpSIeBRrvWtbeBfrpxP9] Failed:     App\Jobs\RunImport
[2021-03-13 00:59:36][gO7YWftHnrLetyiU2Ajg9P6rXFBbbYlJ] Processing: App\Jobs\RunImport
[2021-03-13 00:59:36][gO7YWftHnrLetyiU2Ajg9P6rXFBbbYlJ] Failed:     App\Jobs\RunImport
[2021-03-13 01:04:04][BEAkgmSla6hCiATtfC71yUu1M9Hvfhj8] Processed:  App\Jobs\RunImport
[2021-03-13 01:04:04][PPT6mqKuvCPUSpSIeBRrvWtbeBfrpxP9] Processed:  App\Jobs\RunImport
[2021-03-13 01:04:04][gO7YWftHnrLetyiU2Ajg9P6rXFBbbYlJ] Processed:  App\Jobs\RunImport
Activity icon

Replied to Laravel 6 Kernel Scheduler Creating Duplicate Jobs

Oops cut off the log, [306] is better example in the above.

From reddit, sounds like Laravel doesnt work properly with mysql as a queue driver and I need to go to redis?

Is there some other kind of lock that needs to be done with mysql? 306 for example is tried twice within 2 minutes, the 2nd one being the failure, then the first later finishes near the end of the log

Activity icon

Started a new Conversation Laravel 6 Kernel Scheduler Creating Duplicate Jobs

I'm noticing Laravel is creating duplicate jobs of the same ID, for example in the list below you can see job ID 310 was tried twice (as well as 296,298,305)

[2021-03-12 20:28:04][296] Processing: App\Jobs\RunImport
[2021-03-12 20:28:04][297] Processing: App\Jobs\RunImport
[2021-03-12 20:28:04][298] Processing: App\Jobs\RunImport
[2021-03-12 20:28:04][299] Processing: App\Jobs\RunImport
[2021-03-12 20:28:23][297] Processed:  App\Jobs\RunImport
[2021-03-12 20:28:23][300] Processing: App\Jobs\RunImport
[2021-03-12 20:28:39][301] Processing: App\Jobs\RunImport
[2021-03-12 20:28:57][301] Processed:  App\Jobs\RunImport
[2021-03-12 20:28:57][302] Processing: App\Jobs\RunImport
[2021-03-12 20:29:15][299] Processed:  App\Jobs\RunImport
[2021-03-12 20:29:15][303] Processing: App\Jobs\RunImport
[2021-03-12 20:29:35][300] Processed:  App\Jobs\RunImport
[2021-03-12 20:29:35][296] Processing: App\Jobs\RunImport
[2021-03-12 20:29:36][296] Failed:     App\Jobs\RunImport
[2021-03-12 20:29:36][298] Processing: App\Jobs\RunImport
[2021-03-12 20:29:36][298] Failed:     App\Jobs\RunImport
[2021-03-12 20:29:36][304] Processing: App\Jobs\RunImport
[2021-03-12 20:29:44][304] Processed:  App\Jobs\RunImport
[2021-03-12 20:29:44][305] Processing: App\Jobs\RunImport
[2021-03-12 20:30:05][302] Processed:  App\Jobs\RunImport
[2021-03-12 20:30:05][306] Processing: App\Jobs\RunImport
[2021-03-12 20:32:12][303] Processed:  App\Jobs\RunImport
[2021-03-12 20:32:12][305] Processing: App\Jobs\RunImport
[2021-03-12 20:32:13][305] Failed:     App\Jobs\RunImport
[2021-03-12 20:32:13][306] Processing: App\Jobs\RunImport
[2021-03-12 20:32:13][306] Failed:     App\Jobs\RunImport
[2021-03-12 20:32:13][307] Processing: App\Jobs\RunImport
[2021-03-12 20:32:43][305] Processed:  App\Jobs\RunImport
[2021-03-12 20:32:43][308] Processing: App\Jobs\RunImport
[2021-03-12 20:32:46][308] Processed:  App\Jobs\RunImport
[2021-03-12 20:32:46][309] Processing: App\Jobs\RunImport
[2021-03-12 20:32:50][309] Processed:  App\Jobs\RunImport
[2021-03-12 20:32:50][310] Processing: App\Jobs\RunImport
[2021-03-12 20:33:05][306] Processed:  App\Jobs\RunImport
[2021-03-12 20:33:09][307] Processed:  App\Jobs\RunImport
[2021-03-12 20:33:30][310] Processed:  App\Jobs\RunImport

This log was taken from the output sent to supervisor

[program:laravel-import]
process_name=%(program_name)s_%(process_num)02d
command=php /home/myapp/myapp-console/current/artisan queue:work --queue=import --tries=1 --timeout=21600 -vvv
autostart=true
autorestart=true
user=myapp
numprocs=4
redirect_stderr=true
stdout_logfile=/home/myapp/myapp-console/current/storage/logs/worker-import.log
stopwaitsecs=3600

I have the following schedule in Kernel.php. A datasource is a client specific endpoint where they can set a schedule to have an import be run

protected function schedule(Schedule $schedule) {
  // start jobs on import queue from user defined schedule
  $datasources = Datasource::all();
  foreach ($datasources as $datasource) {
    if (!empty($datasource->schedule) && $datasource->company->active) {
      $schedule->call(function() use ($datasource) {
        Log::channel('import-runtime')->info("Creating new import for {$datasource->datasource_key}");
        $datasource->createImport();
      })->name("datasource-{$datasource->id}")->withoutOverlapping()->cron($datasource->schedule)->runInBackground();
    }
  }
}

The createImport() function adds a job to a worker queue

public function createImport($onDemand = false) {
  $import = new Import();
  $import->datasource_id = $this->id;
  $import->status = 'awaiting';
  $import->start_at = Carbon::now();
  $import->save();
  $queue = $onDemand ? 'import-ondemand' : 'import';
  Log::channel('import-runtime')->info("[ds_{$import->datasource_id}_import_{$import->id}] Import created, adding to queue {$queue}");
  RunImport::dispatch($import)->onQueue($queue);
}

I set everyones schedule to the same cron format '28 20 * * *' and let the workers consume all jobs. I then get errors of Illuminate\Queue\MaxAttemptsExceededException

How can I prevent these jobs from being tried multiple times?

Mar
11
2 months ago
Activity icon

Replied to How Can I Debug `Illuminate\Queue\MaxAttemptsExceededException`

Also interesting is the import continues to run, but I don't see anything in log saying its running twice

Activity icon

Started a new Conversation How Can I Debug `Illuminate\Queue\MaxAttemptsExceededException`

PHP 7.4 Laravel 6.x on Ubuntu 20

We have a bunch of data imports that run daily from various clients at various times. In the Kernel scheduler I have it read the individual cron schedules from each datasource and dispatch a job. Out of dozens I'll get like 5 or 6 that say MaxAttemptsExceededException.

  protected function schedule(Schedule $schedule) {
    // start jobs on import queue from user defined schedule
    $datasources = Datasource::all();
    foreach ($datasources as $datasource) {
      if (!empty($datasource->schedule) && $datasource->company->active) {
        $schedule->call(function() use ($datasource) {
          Log::channel('import-runtime')->info("Creating new import for {$datasource->datasource_key}");
          $datasource->createImport();
        })->cron($datasource->schedule);
      }
    }
  }

The createImport is just a simple function that adds a job to queue

  public function createImport($onDemand = false) {
    $import = new Import();
    $import->datasource_id = $this->id;
    $import->status = 'awaiting';
    $import->start_at = Carbon::now();
    $import->save();
    $queue = $onDemand ? 'import-ondemand' : 'import';
    RunImport::dispatch($import)->onQueue($queue);
  }

We have 4 workers with 6 hour timeout

[program:laravel-import]
process_name=%(program_name)s_%(process_num)02d
command=php /home/my-app/my-app-console/current/artisan queue:work --queue=import --tries=1 --timeout=21600
autostart=true
autorestart=true
user=my-app
numprocs=4
redirect_stderr=true
stdout_logfile=/home/my-app/my-app-console/current/storage/logs/worker-import.log
stopwaitsecs=3600

This is the exception in failed_jobs

Illuminate\Queue\MaxAttemptsExceededException: App\Jobs\RunImport has been attempted too many times or run too long. The job may have previously timed out. in /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Worker.php:632
 Stack trace:
 #0 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(446): Illuminate\Queue\Worker->maxAttemptsExceededException()
 #1 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(358): Illuminate\Queue\Worker->markJobAsFailedIfAlreadyExceedsMaxAttempts()
 #2 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(314): Illuminate\Queue\Worker->process()
 #3 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Worker.php(134): Illuminate\Queue\Worker->runJob()
 #4 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(112): Illuminate\Queue\Worker->daemon()
 #5 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Queue/Console/WorkCommand.php(96): Illuminate\Queue\Console\WorkCommand->runWorker()
 #6 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(36): Illuminate\Queue\Console\WorkCommand->handle()
 #7 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
 #8 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(93): Illuminate\Container\Util::unwrapIfClosure()
 #9 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(37): Illuminate\Container\BoundMethod::callBoundMethod()
 #10 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\Container\BoundMethod::call()
 #11 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\Container\Container->call()
 #12 /home/my-app/my-app-console/releases/43/vendor/symfony/console/Command/Command.php(255): Illuminate\Console\Command->execute()
 #13 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\Component\Console\Command\Command->run()
 #14 /home/my-app/my-app-console/releases/43/vendor/symfony/console/Application.php(1009): Illuminate\Console\Command->run()
 #15 /home/my-app/my-app-console/releases/43/vendor/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
 #16 /home/my-app/my-app-console/releases/43/vendor/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
 #17 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\Component\Console\Application->run()
 #18 /home/my-app/my-app-console/releases/43/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Console\Application->run()
 #19 /home/my-app/my-app-console/releases/43/artisan(37): Illuminate\Foundation\Console\Kernel->handle()
 #20 {main}

None of these jobs when I run them manually last more than a couple hours.

Any ideas on what I can look for next?

Feb
26
2 months ago
Activity icon

Replied to Increase Upload Limit For Specific Paths Only?

it appears you can only use location to set the max at a lower limit that defined in server or http.

so you have to set it high on http, then low on normal routes, then high again on upload.

maybe ill just look into chunking next time

thx tho

Feb
25
2 months ago
Activity icon

Replied to Increase Upload Limit For Specific Paths Only?

Doesn't seem to work. I can return 200 'got here' to verify I have the path correct, but the size is still limited.

If I moved client_max_body_size to the server block it also works, so I know its not a PHP setting

Feb
24
2 months ago
Activity icon

Started a new Conversation Increase Upload Limit For Specific Paths Only?

This is not exactly a Laravel, or even PHP issue, but more nginx.

Has anyone setup nginx to use client_max_body_size for specific paths? Something like /blah/upload gets 250MB while the rest of the app has nginx default

I assume there is a good reason they keep the default so low so I don't want to blanket change the server

Dec
04
5 months ago
Activity icon

Replied to Livewire Syntax Support In PHPStorm

Any luck with this?