Bind message has 6545 parameter formats but 0 parameters

28 Views Asked by At

My backend was working really nice but a few days ago, I started to notice large delays (request that usually took a few hundreds ms now we are talking about 30s and I saw errors in AWS logs. The error is:

driverError: error: bind message has 6545 parameter formats but 0 parameters
      [...]
      QueryFailedError: bind message has 6545 parameter formats but 0 parameters
      query: 'UPDATE "Announcements" SET "view_count" = view_count + 1, "updatedAt" = CURRENT_TIMESTAMP WHERE "id" IN ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30, $31, $32, $33, $34, $35, $36, $37, $38, ... (and the list continues with around 70 000 consecutives ids, which is exactly the same number than the total announcements count)

So I looked at the code which update the view_count number which seems to be the issue but it seemed fine, I printed the announcementIds parameters and it only contains the first batch of 10 announcements which is exactly the number I want to increment view_count. It only increments those 10 announcements view_count so I don't understand why it takes every announcement id in the in. Could you please help me?

const queryRunner = this.connection.createQueryRunner();
            await queryRunner.connect();
            await queryRunner.startTransaction();

            try {
                const announcementIds = results[0].map(announcement => announcement.id);
                console.log("announcements à update =", announcementIds);
                if (announcementIds.length > 0) {
                    await queryRunner.manager
                        .createQueryBuilder()
                        .update(AnnouncementEntity)
                        .set({ viewCount: () => "view_count + 1" })
                        .whereInIds(announcementIds)
                        .printSql()
                        .execute();
                }

                await queryRunner.commitTransaction();

I erased the update view count part but still got the error with another request...

... AND ST_Distance("createdBy"."location", ST_SetSRID(ST_MakePoint($2,$3), 4326)) < $4 AND  ("game"."age" >=  '1'  or  "game"."age" is null) AND "game"."active" = true ) AND ( "announcement"."deleteAt" IS NULL ) AND ( "announcement"."id" IN (206994, 206992, 206991, 206990, 206989, 206987, 206986, 206985, 206984, 206982, 206981, 206980, 206979, 206978, 206977, 206976, 206975, 206974, 206973, 206972, 206971, 206970, 206969, 206967, 206966, 206965, 206964, 206963, 206962, 206961, 206960, 206959, 206958, 206957, 206955, 206954, 206953, 206952, 206951, 206950, 206949, 206948, 206947, 206945, 206944, 206943, 206942, 206941, 206940, 206939, 2069...

Thanks a lot

0

There are 0 best solutions below