Skip to content

Conversation

@guillep2k
Copy link
Member

Fixes #9755

The statistics for the search results are calculated according to a list of IDs returned by the indexer (e.g. bleve), and therefore can't be resolved with a subquery. It currently produces:

2020/02/03 19:45:21 .../xorm/session_raw.go:76:queryRows() [I] [SQL] SELECT count(*) FROM `issue` WHERE (issue.repo_id = ?) AND `issue`.`id` IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,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?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) AND (issue.is_pull=?) AND (issue.is_closed = ?) []interface {}{76, 5028, 4992, 4991, 3394, 3826, 3502, 3948, 3262, 3420, 3130, 3620, 3669, 3679, 3157, 3863, 3905, 3103, 3438, 3629, 3697, 3918, 3945, 3002, 3021, 3151, 3266, 3686, 3687, 3712, 2943, 3635, 3752, 3033, 3063, 3779, 3148, 3792, 3011, 3082, 3095, 3166, 3194, 3199, 3208, 3209, 3213, 3230, 3291, 3293, 3297, 3299, 3353, 3372, 3384, 3391, 3407, 3441, 3551, 3602, 3618, 3654, 3675, 3705, 3726, 3744, 3748, 3763, 3785, 3840, 3849, 3851, 3877, 3883, 3923, 3932, 3085, 3195, 3544, 3584, 3592, 3696, 3765, 3879, 3402, 3415, 3750, 3655, 3051, 3404, 3736, 3855, 2945, 3497, 3578, 4021, 3115, 3348, 3577, 3587, 3114, 3909, 3074, 3120, 3178, 3257, 3343, 3557, 3666, 3695, 3713, 3769, 3832, 3910, 4005, 3823, 3957, 3056, 3070, 3087, 3154, 3193, 3204, 3425, 3546, 3591, 2926, 2956, 2958, 3630, 3211, 3286, 3424, 3616, 3727, 3940, 2912, 2961, 3184, 3445, 3702, 3966, 3023, 3025, 3035, 3058, 3078, 3092, 3105, 3121, 3123, 3124, 3239, 3252, 3253, 3254, 3336, 3361, 3460, 3619, 3668, 3714, 3817, 3822, 3862, 3047, 3788, 3888, 3732, 3852, 2915, 3238, 3335, 3489, 3641, 3643, 3079, 3430, 3646, 3026, 2916, 3176, 3098, 3118, 3179, 3245, 3660, 3808, 2974, 3049, 3062, 3129, 3352, 3371, 3531, 3532, 3664, 3790, 3850, 2905, 3147, 3198, 3393, 4024, 3503, 3031, 3182, 3192, 3048, 3338, 3810, 3964, 3229, 3459, 3651, 3671, 2910, 3787, 3162, 3171, 3206, 3535, 3861, 3984, 3000, 3075, 3113, 3296, 3308, 3427, 3495, 3564, 3595, 3614, 3709, 3717, 3807, 3980, 3131, 3207, 3261, 3476, 3071, 3611, 3061, 3272, 3315, 3547, 3563, 3947, 3982, 3346, 3530, 3403, 3412, 3566, 3853, 3490, 3380, 3399, 3631, 3751, 3645, 3126, 3163, 3241, 3333, 3358, 3429, 3494, 3596, 3642, 3700, 3711, 3589, 3868, 3249, 3805, 3370, 3793, 3066, 3122, 3119, 3170, 3258, 3754, 3903, 3283, 3073, 3222, 3373, 3572, 3970, 3183, 3691, 3008, 3064, 3298, 3561, 3633, 3730, 3740, 3761, 3410, 3472, 3360, 3271, 3518, 3917, 2972, 3405, 3268, 3522, 2904, 3303, 3525, 3581, 3911, 3605, 3214, 2999, 3077, 3081, 3246, 3310, 3451, 3487, 3529, 3556, 3667, 3722, 3815, 3848, 3986, 3275, 3235, 3963, 3432, 3492, 3622, 3107, 3919, 3068, 3426, 3799, 2988, 3526, 3673, 3809, 3839, 3043, 3093, 3155, 3269, 3287, 3625, 3475, 3127, 3570, 3639, 3030, 3248, 3615, 3735, 2968, 3288, 3936, 3386, 3458, 3471, 3576, 3962, 3116, 3819, 3854, 3156, 3295, 3351, 3806, 3244, 3542, 3545, 3285, 3558, 3018, 3385, 3540, 3698, 3804, 3125, 3321, 3381, 3446, 3491, 3501, 3586, 3780, 3789, 3985, 3242, 3181, 3110, 3044, 3326, 3716, 3871, 3965, 3798, 3136, 3247, 3313, 3350, 3534, 3585, 3623, 3647, 3723, 3881, 3927, 3457, 3528, 3601, 3027, 3137, 3519, 3481, 4019, 3196, 3517, 3781, 3959, 3448, 3359, 4023, 3378, 3202, 3749, 3569, 3189, 3382, 3443, 3609, 3747, 3347, 3218, 3755, 3894, 3106, 3413, 3701, 3456, 3693, 3739, 3205, 3159, 3588, 3943, 2983, 3016, 3334, 3354, 3875, 3989, 3827, 3260, 3300, 3203, 3160, 3473, 3703, 2989, 3010, 3046, 3169, 3440, 3598, 3856, 3447, 3210, 2971, 3108, 3161, 3455, 3406, 3624, 3908, 3977, 3237, 3357, 3050, 3188, 3665, 3860, 3379, 3431, 3484, 3878, 3952, 3109, 3479, 3882, 3767, 2973, 3001, 3409, 3454, 3465, 3628, 3800, 3983, 3263, 3259, 3920, 3277, 3401, 3600, 3579, 3029, 3486, 3097, 3377, 3231, 3485, 3593, 3993, 3603, 3613, 3648, 3657, 3681, 3332, 3961, 3493, 3498, 3216, 3818, 3988, 2955, 3423, 3158, 3356, 3764, 3901, 3499, 3225, 3324, 3774, 3842, 3874, 3533, 3594, 3757, 3273, 3364, 3505, 3734, 3039, 3450, 3521, 3560, 3689, 3783, 4012, 3395, 3439, 3786, 3610, 3715, 3567, 3797, 3065, 3224, 3904, 3880, 3464, 3145, 3500, 3550, 3180, 3555, 3096, 3323, 3637, 3539, 3337, 3608, 3847, 3692, 3869, 3312, 3844, 3672, 2913, 3866, 3951, 3172, 3444, 3514, 3813, 3559, 3144, 3758, 3042, 3236, 3470, 3575, 3824, 3265, 3434, 3991, 3045, 3972, 3496, 3833, 3024, 3411, 3037, 3483, 3791, 3302, 3663, 3834, 3935, 3232, 3913, 3067, 3146, 3571, 3971, 3175, 3784, 3987, 3900, 3383, 3374, 3742, 3088, 3419, 3704, 3707, 3872, 3858, 3694, 3803, 3527, 3134, 3375, 3612, 3743, 3737, 3946, 3267, 3721, 3504, 3887, 3100, 3960, 3197, 3367, 3304, 3478, 4020, 3829, 3376, 3548, 4002, 3661, 3892, 3327, 3670, 3677, 3814, 3177, 3554, 3474, 3305, 3020, 3219, 3652, 4010, 3150, 3325, 3682, 4018, 3745, 3738, 3264, 3541, 3912, 3036, 3133, 3520, 3795, 3059, 3369, 3135, 3583, 3421, 3762, 3895, 3060, 3573, 3759, 2907, 3549, 3582, 3461, 3640, 3636, 3389, 4013, 3349, 3606, 3859, 3836, 3857, 3433, 3907, 3876, 3463, 3933, 4017, 3019, 3368, 3688, 3278, 3516, 3801, 3363, 3690, 3140, 3099, 3330, 3981, 3574, 3950, 3891, 3090, 3290, 3638, 4009, 3417, 3453, 3733, 3621, 3893, 3969, 3212, 3466, 3778, 3674, 3846, 3086, 3482, 3990, 3341, 3899, 3835, 3728, 3944, 3509, 3955, 4026, 3568, 3480, 3507, 3294, 3580, 3462, 3746, 3974, 3729, 3256, 3967, 3221, 3902, 3190, 3442, 3449, 3084, 3976, 3864, 3255, 2919, 3281, 3992, 3164, 3782, 3538, 3676, 3437, 3949, 3720, 3930, 3617, 3915, 3867, 3307, 3200, 3080, 3865, 4007, 3934, 3322, 3756, 4001, 3143, 3328, 2944, 3741, 3072, 4004, 3886, 3906, 3069, 3506, 3724, 3890, 3678, 4029, 3013, 3562, 3685, 3607, 3820, 3968, 4030, 3435, 3215, 3392, 3536, 3821, 3537, 3776, 3306, 4014, 3397, 3054, 3958, 3914, 3773, 3634, 2938, 4022, 3884, 3488, 3524, 3979, 3653, 4006, 4016, 3873, 3513, 3995, 3331, 3775, 3938, 4003, 3731, 3812, 3684, 3898, 3165, 3301, 4011, 3889, 3994, 3916, 3828, 3345, 3649, 3942, 3896, 3365, 3941, 3102, 4028, 3802, 3523, 3838, 3228, 4015, 4025, 3510, 3220, 3128, 3843, 3436, 3796, 3223, 4008, 3416, 3897, 3604, 3243, 3975, 3978, 3467, 3753, 3132, 3329, 2932, 3931, 3956, 3152, 3777, 3289, 3390, 3973, 3760, 3217, 3511, 3768, 3937, 4027, 3400, 3922, 3770, 3022, 3477, 3185, 3201, 3355, 3251, 3292, 3939, 3226, 3041, 3362, 3837, 3280, 3841, 3191, 3953, 3083, 3101, 3543, 3885, 3276, 3227, 3015, 3825, 3186, 2975, 2976, 2977, 2978, 2979, 2980, 2981, 2982, 2984, 2985, 2986, 2987, 2990, 2991, 2992, 2993, 2994, 2995, 2996, 2997, 2998, 3003, 3004, 3005, 3006, 3009, 3012, 3014, 3017, 3034, 3055, 3057, 3076, 3089, 3091, 3094, 3117, 3138, 3139, 3141, 3142, 3149, 3167, 3168, 3173, 3174, 3233, 3234, 3240, 3250, 3270, 3274, 3279, 3282, 3284, 3309, 3311, 3314, false, false} - took: 224.996µs
2020/02/03 19:45:21 ...outers/repo/issue.go:177:issues() [E] GetIssueStats: too many SQL variables

This PR solves this problem by querying the database in smaller chunks to produce the stats.

@codecov-io
Copy link

codecov-io commented Feb 7, 2020

Codecov Report

Merging #10176 into master will increase coverage by <.01%.
The diff coverage is 65.51%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #10176      +/-   ##
==========================================
+ Coverage   43.64%   43.65%   +<.01%     
==========================================
  Files         584      585       +1     
  Lines       80984    81010      +26     
==========================================
+ Hits        35348    35366      +18     
- Misses      41251    41261      +10     
+ Partials     4385     4383       -2
Impacted Files Coverage Δ
models/fixture_generation.go 65.38% <65.38%> (ø)
models/unit_tests.go 69.42% <66.66%> (ø) ⬆️
models/unit.go 37.03% <0%> (-2.47%) ⬇️
services/pull/check.go 31.09% <0%> (-1.83%) ⬇️
modules/queue/workerpool.go 46.61% <0%> (-1.07%) ⬇️
modules/log/event.go 64.61% <0%> (-1.03%) ⬇️
models/error.go 30.4% <0%> (-0.55%) ⬇️
models/gpg_key.go 55.37% <0%> (+0.55%) ⬆️
services/pull/pull.go 33.93% <0%> (+1.5%) ⬆️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f7041e2...7746139. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 7, 2020
@guillep2k
Copy link
Member Author

guillep2k commented Feb 7, 2020

I went for 200 300 IDs per chunk; we could maybe tune this up a little (SQLite has a total limit of 999 AFAIK).

Copy link
Member

@6543 6543 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm it is not a bad solution ... in future we will have #9787 ...

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Feb 7, 2020
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Feb 13, 2020
@sapk sapk merged commit 15614a8 into go-gitea:master Feb 15, 2020
@lunny
Copy link
Member

lunny commented Feb 15, 2020

Please send bacport to v1.11.1

guillep2k added a commit to guillep2k/gitea that referenced this pull request Feb 15, 2020
* Divide GetIssueStats query in smaller chunks

* Skip chunking if count is low enough

* Fix lint

* Define maxQueryParameters

* Remove absMaxQueryParameters because of lint

* Restart CI

* Restart CI

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
@lafriks lafriks added the backport/done All backports for this PR have been created label Feb 15, 2020
lafriks added a commit that referenced this pull request Feb 15, 2020
* Divide GetIssueStats query in smaller chunks

* Skip chunking if count is low enough

* Fix lint

* Define maxQueryParameters

* Remove absMaxQueryParameters because of lint

* Restart CI

* Restart CI

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: Lauris BH <[email protected]>

Co-authored-by: Lunny Xiao <[email protected]>
Co-authored-by: zeripath <[email protected]>
Co-authored-by: Lauris BH <[email protected]>
@guillep2k guillep2k deleted the fix-9755 branch February 15, 2020 18:16
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport/done All backports for this PR have been created lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

template: executing "repo/issue/list" at <eq $.MilestoneID .ID>: error calling eq: invalid type for comparison

8 participants