Skip to content

Commit fe2c924

Browse files
committed
Use BIGINT for in_bytes to avoid overflows
1 parent 737a8d6 commit fe2c924

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

dbutils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,8 @@ def migration_step_2():
154154
def migration_step_3():
155155
with get_db_cursor() as c:
156156
c.execute(f'CREATE TABLE {DB_PREFIX}exporters (ip INET NOT NULL PRIMARY KEY);')
157+
158+
def migration_step_4():
159+
with get_db_cursor() as c:
160+
# INTEGER (signed 32 bits) is not enough for in_bytes:
161+
c.execute(f"ALTER TABLE {DB_PREFIX}flows ALTER COLUMN in_bytes SET DATA TYPE BIGINT;")

netflowwriter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _pgwriter_write(pgwriter, ts, client_ip, IN_BYTES, PROTOCOL, DIRECTION, L4_D
5757
11, # number of columns
5858
4, int(ts), # integer - beware of Y2038 problem! :)
5959
8, IPV4_PREFIX, socket.inet_aton(client_ip), # 4 bytes prefix + 4 bytes IP
60-
4, IN_BYTES, # integer
60+
8, IN_BYTES, # bigint
6161
2, PROTOCOL,
6262
2, DIRECTION,
6363
4, L4_DST_PORT,

0 commit comments

Comments
 (0)