Login
Username: Password:
Remember me

[Sign Up] / [Recover Password]

Theme / Language

Popular
New Torrents
new name
Size: 18.40 MB
Most active
new name
S: 74 L: 3
New Posters
Announce - BIGINT Errors
Controls ·  Search New posts · Mark unread

You are in: Forum / Forum / Torrent Trader / v3 Support

2020-06-09 02:12:06
I have been trying to tackle for this quite a while, and I know I can take this to stack-overflow, but as we all use the same script its better to ask here.

Ive been dealing with this for months:


Database Error in announce.php on line 379: BIGINT UNSIGNED value is out of range in '`db1`.`torrents`.`leechers` - 1'. Query was: UPDATE torrents SET leechers = leechers - 1,seeders = seeders + 1,visible = 'yes',last_action = '2020-06-08 20:46:39' WHERE id=1017


I can't figure this out, I've increased and tried modifying field type in database, but it creeps back to the error above anyway. Does anyone know what this is about?
2020-06-09 09:24:25
Where in torrent table do you have bigint
Size is a bigint  just wondering if you edited the structure.
2020-06-09 10:17:43
I have torrent/seeders/leechers set to INT length of 10, is that value sufficient? I can't remember changing it, but did look at it some months ago
2020-06-10 11:07:39
a quick look at my db and I dont have any BIGINT in my announce table, only INT
TTv3 Micro Edition
Ubuntu 20.04.6 LTS Server
Mysql Version: 10.3.39-MariaDB-0ubuntu0.20.04.2
PHP Version: 7.4.3-4ubuntu2.20
Apache Version: Apache/2.4.59 (Ubuntu)
2020-06-10 11:15:20
I once faced it on xbtit. Mainly caused by unsupported date time format.
2020-06-11 01:53:49
Thank you guys! I'll look into date format and see what might be going on.
2020-06-12 13:44:04
i was wondering about that error for a while now since i also have that error in my site log i have to clear the logs regularly or the amount of pages gets very big

[ATTACH]5588[/ATTACH]
Screenshot_2.png
Screenshot_2.png

Torrent Trader PDO/MVC 2021
Xampp Windows 10 21H1
Apache Version: Apache/2.4.48 (Win64)
Mysql Version: 10.4.20-MariaDB
PHP Version: 8.0.9
2020-06-12 16:04:37
Interesting, So I aim to break down this join and merge the columns in manually. First I will seek to replace join on code examples and keep “cleaning” until the sqlerr sees no entries. I think this bug went unnoticed, or was not tested on large databases.

i can tick each one ‘ that typically used to handle larger databases, but I don’t think that will do it. Will post my progress!
2020-07-06 20:23:55
Digging deeper, this appears to be compatibility issue past MySQL 5.6.x, I’m curious if anyone on later versions of mysql/mariadb have this issue?

The problem is negative values in the torrents.leechers, where it is not handling negative integers.
The solution is to CAST as SIGNED in the last query line in announce.php, which I might still do.

Alternatively, add to my.cnf under [mysqld]

sql_mode = "NO_ENGINE_SUBSTITUTION"
Unknown User
2020-07-06 22:13:21
The issue is the number can become negative, it should only subtract if numbers are both positive.
2020-07-07 00:02:04
"mostvotedplaya, post: 68790, member: 20335":

The issue is the number can become negative, it should only subtract if numbers are both positive.


Interesting. Thanks for input, do you know if this is a known bug? I can force handling in my.cnf but I really want to get at the query and CAST the value as UNSIGNED, however since we are dealing with negative int's (subtracting from column for example), I wonder if I can use it there. Of course, each code edit results in a full clean off of admincp and right back to sqlerror log page (or view table in my client).

I've been through this today from left to right, to understand this issue and resolve. I believe it is throwing tracker stats off for some users too, as they are complaining about the same specific scenario. I encourage to change ports on torrent client and wait for announce interval, but that is not a solution.

I return back to this issue because my sqlerror log is jammed with these errors from announce.php on a daily basis. I never saw this before the move to MariaDB.

SO on this topic
[URL unfurl="true"]https://stackoverflow.com/questions/5605085/bigint-unsigned-value-is-out-of-range[/url]

So at this point I really want to just strip all the update sets and just foreach all of it in a array, as already in design. This made sense initially.

Issue:


if (count($updateset))
   SQL_Query_exec("UPDATE torrents SET " . join(",", $updateset) . " WHERE id=$torrentid") or err("Tracker error: Unable to update torrent");


So my idea is crunching down [color=rgb(84, 172, 210)]join()[/color] on [color=rgb(251, 160, 38)]$updateset [/color][color=rgb(209, 213, 216)]and go from there. Thoughts?[/color]
2020-07-07 01:12:24
I have fixed it, no more errors. Peer table looks better. I updated away from alias function join() to implode() and added whitespace between quotes.

SQL_Query_exec("UPDATE torrents SET " . implode(", ", $updateset) . " WHERE id=$torrentid") or err("Tracker error: Unable to update torrent");
Unknown User
2020-07-08 22:11:22
[url='https://dev.mysql.com/doc/refman/8.0/en/integer-types.html']BIGINT[(M)] [UNSIGNED] [ZEROFILL][/url]

A large integer. The signed range is-9223372036854775808 to9223372036854775807. The unsigned range is 0to 18446744073709551615.

just check the fields are above 0 for subtraction, because unsigned prevent anything Lower than 0
2020-07-15 06:41:12
"mostvotedplaya, post: 68800, member: 20335":

[url='https://dev.mysql.com/doc/refman/8.0/en/integer-types.html']BIGINT[(M)] [UNSIGNED] [ZEROFILL][/url]

A large integer. The signed range is-9223372036854775808 to9223372036854775807. The unsigned range is 0to 18446744073709551615.

just check the fields are above 0 for subtraction, because unsigned prevent anything Lower than 0


INT(50) currently, which seems wrong to me in terms of field type. My second attempt using CAST() - not advised but a cheat more so:


////////////////// NOW WE DO THE TRACKER EVENT UPDATES ///////////////////

if ($event == "stopped") { // UPDATE "STOPPED" EVENT
       SQL_Query_exec("DELETE FROM peers WHERE $selfwhere");
       if (mysql_affected_rows()){
           if ($self["seeder"] == "yes")
               $updateset[] = "seeders = seeders - CAST(1 AS SIGNED)";
           else
               $updateset[] = "leechers = leechers - CAST(1 AS SIGNED)";
       }
}

if ($event == "completed") { // UPDATE "COMPLETED" EVENT  
   $updateset[] = "times_completed = times_completed + CAST(1 AS SIGNED)";

   if ($MEMBERSONLY)
       SQL_Query_exec("INSERT INTO completed (userid, torrentid, date) VALUES ($userid, $torrentid, '".get_date_time()."')");
}//END COMPLETED

if (isset($self)){// NO EVENT? THEN WE MUST BE A NEW PEER OR ARE NOW SEEDING A COMPLETED TORRENT
 
   SQL_Query_exec("UPDATE peers SET ip = " . sqlesc($ip) . ", passkey = " . sqlesc($passkey) . ", port = $port, uploaded = $uploaded, downloaded = $downloaded, to_go = $left, last_action = '".get_date_time()."', client = " . sqlesc($agent) . ", seeder = '$seeder' WHERE $selfwhere");

   if (mysql_affected_rows() && $self["seeder"] != $seeder){
       if ($seeder == "yes"){
           $updateset[] = "seeders = seeders + CAST(1 AS SIGNED)";
           $updateset[] = "leechers = leechers - CAST(1 AS SIGNED)";
       } else {
           $updateset[] = "seeders = seeders - CAST(1 AS SIGNED)";
           $updateset[] = "leechers = leechers + CAST(1 AS SIGNED)";
       }
   }

} else {

   $ret = SQL_Query_exec("INSERT INTO peers (connectable, torrent, peer_id, ip, passkey, port, uploaded, downloaded, to_go, started, last_action, seeder, userid, client) VALUES ('$connectable', $torrentid, " . sqlesc($peer_id) . ", " . sqlesc($ip) . ", " . sqlesc($passkey) . ", $port, $uploaded, $downloaded, $left, '".get_date_time()."', '".get_date_time()."', '$seeder', '$userid', " . sqlesc($agent) . ")");
 
   if ($ret){
       if ($seeder == "yes")
           $updateset[] = "seeders = seeders + CAST(1 AS SIGNED)";
       else
           $updateset[] = "leechers = leechers + CAST(1 AS SIGNED)";
   }
}

//////////////////    END TRACKER EVENT UPDATES ///////////////////
[/PHP]
Unknown User
2020-07-15 09:48:52
The int(50) is 50 characters of padding for programs like phpmyadmin so the correct thing to do would be to use unsigned big int, the range starts from zero up to the number described above.


you can do something like if seeders over 0 then subtract 1 else use 0

I
Users online

No users online

Search



Statistics

    Torrents

  • Tracking: 3
  • Todays torrents: 0
  • Seeders: 0
  • Leechers: 0
  • Peers: 0
  • Downloaded: 89.96 GB
  • Uploaded: 9.86 GB

  • Members

  • We have: 838
  • New today: 0
  • Guest today: 9

  • Online

  • Total online: 1
  • Members: 0
  • Guests online: 1
  • Comments: 3
  • Messages: 1,728