Skip to content

[Bug]: task had been submitted but not executed #355

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
RyanChen1997 opened this issue Jan 15, 2025 · 8 comments
Closed
3 tasks done

[Bug]: task had been submitted but not executed #355

RyanChen1997 opened this issue Jan 15, 2025 · 8 comments
Assignees
Labels
bug Something isn't working stale

Comments

@RyanChen1997
Copy link

Actions I've taken before I'm here

  • I've thoroughly read the documentations on this issue but still have no clue.
  • I've searched the current list of Github issues but didn't find any duplicate issues that have been solved.
  • I've searched the internet with this issue, but haven't found anything helpful.

What happened?

I submit task successfully, but the task is not executed.

Init pool:

func InitPool() {
	var err error
	GoPool, err = ants.NewPool(11, ants.WithPanicHandler(
		func(i interface{}) {
			stack := string(debug.Stack())
			llog.Errorf(context.Background(), "[GoPool] panic: %v | Stack Trace:%s", i, stack)
		},
	))
	if err != nil {
		llog.Fatalf(context.Background(), "init GoPool failed: %s", err)
	}
}

submit task

func run() {
        ctx := context.TODO()
	task, err := db.GetReadyTasks(ctx)
	if err != nil {
		llog.Errorf(ctx, "[TriedDrivingDetectCron] get ready tasks failed: %v", err)
	}
	for _, task := range task {
		err = db.DelDataProcessTaskByTaskKey(ctx, task.TaskKey, db.DataProcessTaskTypeTiredDriving)
		if err != nil {
			llog.Errorf(ctx, "[TriedDrivingDetectCron] del task failed task: %+v err: %v", task, err)
			continue
		}
		llog.WithContext(ctx).Infof("[TriedDrivingDetectCron] start detect task. TaskKey=%s, TaskType=%d", task.TaskKey, task.TaskType)
		err = pool.GoPool.Submit(func() {
			llog.WithContext(ctx).Debugf("[TriedDrivingDetectCron] start detect goroutine. taskKey=%s", task.TaskKey)
			_, err := TiredDrivingDetect(ctx, task)
			if err != nil && !errors.Is(err, ErrOrderIsNotOnGoing) {
				llog.Errorf(ctx, "[TriedDrivingDetectCron] detect failed: %v. taskKey=%s", err, task.TaskKey)
			}
		})
		if err != nil {
			llog.Errorf(ctx, "[TriedDrivingDetectCron] submit task failed: %v. taskKey=%s", err, task.TaskKey)
		} else {
			llog.WithContext(ctx).Debugf("[TriedDrivingDetectCron] end detect task. TaskKey=%s, TaskType=%d", task.TaskKey, task.TaskType)
		}
	}
}

func TiredDrivingDetect(ctx context.Context, task db.DataProcessTask) (result DetectCounter, err error) {
	llog.WithContext(ctx).Debugf("[tiredDrivingDetect] get task: %+v", task)
	var detail TiredDrivingTaskDetail

	err = jsoniter.UnmarshalFromString(task.Detail, &detail)
	if err != nil {
		llog.Errorf(ctx, "[TriedDrivingDetectCron] parse detail failed: %v. detail=%s", err, task.Detail)
		return
	}
...
}

get log like this:
image

Major version of ants

v1

Specific version of ants

v1.3.0

Operating system

Linux

OS version

Linux 5.10.134-17.3.al8.x86_64 x86_64

Go version

go1.20.13

Relevant log output

It is mentioned above

Code snippets (optional)

No response

How to Reproduce

Steps to reproduce the behavior:

  1. Go to '....'
  2. Click on '....'
  3. Do '....'
  4. See '....'

Does this issue reproduce with the latest release?

It can reproduce with the latest release

@RyanChen1997 RyanChen1997 added the bug Something isn't working label Jan 15, 2025
@panjf2000
Copy link
Owner

Please upgrade to v2, v1 is no longer maintained.

@RyanChen1997
Copy link
Author

Please upgrade to v2, v1 is no longer maintained.

I have try v2, it has the same issue.

@panjf2000
Copy link
Owner

What specific v2 version have you tried?

@panjf2000
Copy link
Owner

Your example involved too much business logic, please provide a reproducer without these business logic.

@turkishjoe
Copy link

Has a simular issue. I have no idea how to resolve it.

@POABOB
Copy link
Contributor

POABOB commented Mar 6, 2025

Has a simular issue. I have no idea how to resolve it.

Ser, maybe you can provide a reproducer with simple logic. We can try to figure it out~

Copy link

github-actions bot commented Apr 6, 2025

This issue is marked as stale because it has been open for 30 days with no activity.

You should take one of the following actions:

  • Manually close this issue if it is no longer relevant
  • Comment if you have more information to share

This issue will be automatically closed in 7 days if no further activity occurs.

@github-actions github-actions bot added the stale label Apr 6, 2025
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

If you believe this is a false alarm, please leave a comment for it or open a new issue, you can also reopen this issue directly if you have permission.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

4 participants