Repository navigation
Fix DB integer out of range error - #8390
Conversation
* convert build id related columns to type bigint in DB * advisoring lock will be computed from build_id%max_int * for build events, select on build id only when it is beyond max_int so it wont query old build id (integer type) with a beyond max_int value and fail the query Signed-off-by: Rui Yang <[email protected]>
|
|
||
| func NewBuildTrackingLockID(buildID int) LockID { | ||
| return LockID{LockTypeBuildTracking, buildID} | ||
| return LockID{LockTypeBuildTracking, buildID % MaxInt} |
There was a problem hiding this comment.
Like I suggested in #8364 (comment), I still think the change should be in LockID.toDBArgs(). This is not just a problem with build id, I would consider volume id, container id to be larger than build id. As the restriction comes from PG, the fix should be as close as possible to db related code.
If you change LockID.toDBArgs(), please add some tests accordingly.
There was a problem hiding this comment.
For hush-house (being up for 4 years), we have the maximum ids as following
1081477231 build id
214934158 container id
410257222 volumn id
Could you list the ids in runway for comparation? Ideally I want to keep the impact as minimum as possible, until we see the same problem reported for container/volumn ID.
I can see a trend that the increasing of build ID will be way faster than container/volume ids since in 7.0 all checks run as build. But for other IDs I think their grow should be the same as before.
There was a problem hiding this comment.
On our prod cluster (6.7.8):
10422031 build id
308650846 container id
707639294 volume id
In theory, a build needs to run a least one container and one volume, thus container id and volume id should be consumed faster than build id.
In your cluster, I think check builds (before in-memory check build) wasted a lot of build ids, many checks didn't actually run anything. After in-memory check build is in place, only a check build that really runs should consume a build id.
There was a problem hiding this comment.
if runway is in 6.7.8, it doesn't have in-memory check build either. How come its maximum build id is like that? How long has been the cluster up and running?
There was a problem hiding this comment.
Our prod cluster has been running for ~3 years. To roughly calculate, say 1000 working days, 10422031 / 1000 = 10422 builds per day, that's a reasonable number. As most of builds are triggered by code check-in.
Remember that, 6.x uses checks table, so that checks doesn't consume any build id.
From the other perspective, majority workloads on our cluster are coming from checks, that's reason why I spent so much efforts on optimizing checks.
There was a problem hiding this comment.
I don't really want to add this overhead dividen operation to not needed lock ids so to me LockID.toDBArgs() is the least place I want to solve the problem. Plus the way you suggested will also calculate the lock_type % maxint32 which seems unnecessary.
I agree that volume id and container id should be considered though. However it seems there is no lock ID that depends on container ID.
There was a problem hiding this comment.
Comparing to the following DB operation pg_try_advisory_lock, cost of % operator can be ignored.
With your current implementation, there are still potential problems:
- When container_id related lock is added, or other lock types that need build id or volume id are added, future developers have to remember
% MaxInt32, which is error-prone. - Job id, resource configure id may eventually reach to MaxInt32 though possibility is low.
The following implementation will not % lock type:
func (l LockID) toDBArgs() []interface{} {
result := []interface{}{l[0]}
if len(l) > 1 {
result = append(result, l[1] % math.MaxInt32)
}
return result
}There was a problem hiding this comment.
- When container_id related lock is added, or other lock types that need build id or volume id are added, future developers have to remember
% MaxInt32, which is error-prone.
I have added a block of comment for furture reference of developing lock type. Plus I can hardly imagine there will be a change of existing lock type or adding a new one.
There was a problem hiding this comment.
TBH, I am not convinced. I still think the change should be in toDBArgs(). But anyway I don't want to block you.
Signed-off-by: Rui Yang <[email protected]>
Signed-off-by: Rui Yang <[email protected]>
|
@xtremerui It seems I have no permission to approve this PR, thus just putting a comment here: LGTM, Approved. |
|
Thank you for reviewing @evanchaoli ! |
Changes proposed by this PR
closes #8364
closes #6354
convert build id related columns to type bigint in DB
build tracking lock id will be computed from build_id%max_int
for build events, select on build id only when it is beyond max_int so it wont query old build id (integer type) with a beyond max_int value and fail the query
done
todo
Release Note