Skip to content

TMS: stuck or missing trips

Sometimes a customer reports that they have a "stuck trip". Here you can read what it means and how to proceed.

tms_planner

  1. Stuck trip in tms_planner, state has not automatically been set to the correct state as the trip was completed.

Recurring: Stable and Nightly database: trip stuck on operator application (https://app.clickup.com/t/86bwepywq)

tms_planner=> BEGIN ;
BEGIN
tms_planner=*> SELECT index, uuid, org_uuid, state FROM trip WHERE uuid = '<TRIP-UUID-HERE>';
  index  |                 uuid                 |               org_uuid               | state 
---------+--------------------------------------+--------------------------------------+-------
 2009962 | 422ffd79-928a-495d-a54e-d5f1e1714243 | 87057c8c-5548-4a99-a10e-d1e50385d0c5 |     5
(1 row)

tms_planner=*> UPDATE trip SET state = 6 WHERE uuid = '<TRIP-UUID-HERE>' RETURNING uuid,state;
                 uuid                 | state 
--------------------------------------+-------
 422ffd79-928a-495d-a54e-d5f1e1714243 |     6
(1 row)

UPDATE 1
tms_planner=*> COMMIT ;
COMMIT
  1. Trip is stuck somewhere else, no matching rows can be found with the given UUID.
    1. There may be a stuck route_stop in tms_planner or stuck booking in tms_booking: Note: you have to know what these states mean in order to be able to fix the issues. You may have to ask for help from a developer like @Koste Sibinovski or @Jonne Nauha.
tms_planner=> SELECT trip_index, state FROM route_stop WHERE booking_uuid = '<BOOKING-UUID-HERE>';
-[ RECORD 1 ]-------
trip_index | 1968953
state      | 2
-[ RECORD 2 ]-------
trip_index | 1968953
state      | 1
-[ RECORD 3 ]-------
trip_index | 1968953
state      | 1

tms_planner=> BEGIN ;
BEGIN
tms_planner=*> UPDATE route_stop SET state = 5 WHERE trip_index = 1968953 RETURNING state;
-[ RECORD 1 ]
state | 5
-[ RECORD 2 ]
state | 5
-[ RECORD 3 ]
state | 5
tms_booking=> SELECT index, state FROM booking WHERE uuid = '<BOOKING-UUID-HERE>';
  index  | state 
---------+-------
 1945098 |     5
(1 row)
tms_planner=*> COMMIT ;
COMMIT

tms_booking

tms_booking=> BEGIN ;
BEGIN
tms_booking=*> UPDATE booking SET state = 9 WHERE uuid = '<BOOKING-UUID-HERE>' RETURNING index, uuid, state;
  index  |                 uuid                 | state 
---------+--------------------------------------+-------
 1945098 | 2fae165e-a50a-4176-8071-7d5a22c5b14c |     9
(1 row)

UPDATE 1
tms_booking=*> COMMIT ;
COMMIT

tms_fleet

tms_fleet=> SELECT index, uuid, org_uuid, state, bill->'state' AS bill_state FROM trip_bill WHERE uuid = '199c099a-5816-4c50-bf07-09e796659580';
  index  |                 uuid                 |               org_uuid               | state | bill_state 
---------+--------------------------------------+--------------------------------------+-------+------------
 2156102 | 199c099a-5816-4c50-bf07-09e796659580 | 87057c8c-5548-4a99-a10e-d1e50385d0c5 |   100 | 100
(1 row)

tms_fleet=> BEGIN ;
BEGIN
tms_fleet=*> UPDATE trip_bill 
SET bill = jsonb_set(bill, '{state}', '1', true)
WHERE uuid = '199c099a-5816-4c50-bf07-09e796659580' RETURNING index, uuid, org_uuid, state, bill->'state' AS bill_state;
  index  |                 uuid                 |               org_uuid               | state | bill_state 
---------+--------------------------------------+--------------------------------------+-------+------------
 2156102 | 199c099a-5816-4c50-bf07-09e796659580 | 87057c8c-5548-4a99-a10e-d1e50385d0c5 |   100 | 1
(1 row)

UPDATE 1
tms_fleet=*> UPDATE trip_bill SET state = 1 WHERE uuid = '199c099a-5816-4c50-bf07-09e796659580' RETURNING index, uuid, org_uuid, state, bill->'state' AS bill_state;
  index  |                 uuid                 |               org_uuid               | state | bill_state 
---------+--------------------------------------+--------------------------------------+-------+------------
 2156102 | 199c099a-5816-4c50-bf07-09e796659580 | 87057c8c-5548-4a99-a10e-d1e50385d0c5 |     1 | 1
(1 row)

UPDATE 1
tms_fleet=*> COMMIT ;
COMMIT