makernexus / Online_Visitor_Log

Other
0 stars 3 forks source link

ENH: Provide the capability to have multiple print servers running at the same time #8

Open BobGlicksman opened 9 months ago

BobGlicksman commented 9 months ago

The architecture allows the OVL system to have multiple print servers all running at the same time. However, the code for OVLcheckincheckout.php does not lock records when querying for unprinted record values and then setting the printed flag on the record. Therefore, more than one print server might pick up the same badge and multiple badge prints can occur. An enhancement would be to add some record locking into this PHP script so that multiple print servers can be accommodated and they won't print duplicate badges.

gregmakernexus commented 9 months ago

There are two approaches I can think of. 1. use the last name, filter each printserver to only print a range of last names. 2. create a central manager in the database to register print servers and allocate labels based on some algorithm. If we use #1, the raspberry pi will need keyboard and monitor to specify the range of names. #1 is the easiest to implement.

BobGlicksman commented 9 months ago

There should be some way to lock out instances of the script from querying the database while one prior instance retrieves the data to be printed and writes the printed flag. This latter instance re-enables database queries after the complete query-mark printed operation has taken place.

If the database itself doesn't provide some mechanism to do this, we can always add in a flag and manage it in the script ourselves. There might be a very tiny chance of a second instance getting into the database just before the first instance locks out queries, but this would occur very very infrequently and it's not worth worrying about. It it did happen, the consequence would be printing some extra badges.

gregmakernexus commented 9 months ago

Again. We would need to notify the database software how many printers, and who they are (probably ip address), then feed the labels appropriately. It is simpler to get all the labels at the print server and only print a range of labels based on last name.
e.g. printer#1 a-f printer#2 g-s printer#3 t-z

If you ever attend a 10k race, they pass out numbers based on last name. Same concept.

jschrempp commented 9 months ago

From MySQL manual

A record lock is a lock on an index record. For example, SELECT c1 FROM t WHERE c1 = 10 FOR UPDATE; prevents any other transaction from inserting, updating, or deleting rows where the value of t. c1 is 10 . Record locks always lock index records, even if a table is defined with no indexes.

gregmakernexus commented 9 months ago

From what I understand, any label can appear on any printer. The variable is when the printer reads the database. Someone would have to find the label.

BobGlicksman commented 9 months ago

You are correct, Greg. The use cases are (1) for very high volume badge printing, and (2) have some print capability when a printer is down. In both of these cases, the printers would be co-located where a staff person would be collecting the badges and handing them out.