[go: up one dir, main page]

CN110175080A - Guarantee the method for data thread safety in goods entry, stock and sales software - Google Patents

Guarantee the method for data thread safety in goods entry, stock and sales software Download PDF

Info

Publication number
CN110175080A
CN110175080A CN201910459192.5A CN201910459192A CN110175080A CN 110175080 A CN110175080 A CN 110175080A CN 201910459192 A CN201910459192 A CN 201910459192A CN 110175080 A CN110175080 A CN 110175080A
Authority
CN
China
Prior art keywords
queue
unit
thread
feature unit
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910459192.5A
Other languages
Chinese (zh)
Inventor
王航
赵俊辉
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Youpi Network Technology Co Ltd
Original Assignee
Shanghai Youpi Network Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Youpi Network Technology Co Ltd filed Critical Shanghai Youpi Network Technology Co Ltd
Priority to CN201910459192.5A priority Critical patent/CN110175080A/en
Publication of CN110175080A publication Critical patent/CN110175080A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/08Logistics, e.g. warehousing, loading or distribution; Inventory or stock management
    • G06Q10/087Inventory or stock management, e.g. order filling, procurement or balancing against orders

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Economics (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • Tourism & Hospitality (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Strategic Management (AREA)
  • Human Resources & Organizations (AREA)
  • Entrepreneurship & Innovation (AREA)
  • General Business, Economics & Management (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Development Economics (AREA)
  • General Engineering & Computer Science (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The present invention relates to field of computer technology, more particularly to guarantee the method for data thread safety in a kind of goods entry, stock and sales software, in goods entry, stock and sales software database repeatable-read rank, using a business paper as an atomic transaction unit in entire operation flow, and be stored in each transaction units as a feature object in a customized queue, handle, which is successively obtained, according to certain sequence executes corresponding business;After each intra-node filters out the business unit needed to be implemented in the cluster, the characteristic information of this element is registered to zookeeper, realizes the queue of data, according to successively successively executing business unit.This method is specifically for procurement, sales, inventory business, it ensure that commodity stocks quantity, cost data will not be because of the concurrent of multithreading and while generating mistake, also improve thread as far as possible can concurrent feasibility, it is different from the mode that traditional core code single thread executes, greatly improve the execution efficiency of procurement, sales, inventory business.

Description

Guarantee the method for data thread safety in goods entry, stock and sales software
Technical field
The present invention relates to the sides for guaranteeing data thread safety in field of computer technology more particularly to a kind of goods entry, stock and sales software Method.
Background technique
Goods entry, stock and sales software is to carry out whole process track management to material stream in enterprise production and management, cash flow, is related to from obtaining Order contract starts, and into material procurement, is put in storage, receives until product completion is put in storage, delivers goods, collects loans, pays raw material The whole link such as money.Goods entry, stock and sales software effectively auxiliary enterprises can solve service management, distributing management, inventory management, marketing program Execution and monitoring, the collection of statistical information etc. traffic issues.When goods entry, stock and sales software provides clothes simultaneously for multiple users When business, the thread-safe of core data is exactly one and has to solve the problems, such as, otherwise operates when simultaneously to same commodity When, the mistake of data can inevitably occur, and the mistake of data once occurs, later data can all go on making mistakes always, therefore must The mechanism that thread-safe is added must be used.
Currently, thread-safe is ensured by the mechanism of speech level, main principle is when one section is marked as The code of thread-safe is performed, this implementation procedure enters the mode that a sequence executes, and the running environment of software is protected Having demonstrate,proved this section of code will not be performed simultaneously, to ensure that the data in code will not generate mistake, but this guarantee thread There are some problems for the mechanism of safety, especially when the execution frequency of this section of code logic is higher, the operational efficiency meeting of system It can not be executed and tie down parallel by this section of code.
Inventory data is into depositing most important basic data in pin software, and the operation of inventory data exactly executes frequency highest Code, almost every business requires change inventory data, when depositing software simultaneously into multiple users using pin and will lead into pin The overall operation efficiency for depositing software is low.
Summary of the invention
For, into the low problem of pin software operation efficiency is deposited, the present invention proposes a kind of into pin under existing multi-user environment Deposit the method for guaranteeing commodity stocks related data thread safety in software.
The method for guaranteeing data thread safety in goods entry, stock and sales software of the invention, is applied to commodity stocks data and cost number According to this method is characterized in that setting db transaction rank to " repeatable read repeatable-read ", realizes step such as Under:
1) it identifies the atomic transaction unit in procurement, sales, inventory business, there is any information unauthorized then all to return to entire transaction units Rolling operation;
2) tenant's level queue is created according to tenant's NameSpace, queue is realized using LinkedList;Each tenant is using During all can individually create oneself execution queue;
3) specific atoms transaction units business is passed through dynamic generation by the specific atomic transaction unit requests of typing Reason, is stored in corresponding queue;
4) queue waits algorithm, and current signature unit A is appended to queue end after obtaining queue, start simultaneously at circulation searching it Preceding element contains duplicate synchronous id with the presence or absence of feature unit B.
Specifically, feature object has with properties in step 3):
Thread counter, that is, monitor whether the previous element that current atomic transaction unit is lined up is released;
Synchronous id set, that is, lead to the problem of the Data Identification of concurrent data;
Executor id, that is, the thread name bound identify the thread in execution.
Specifically, queue waits the judgment rule of feature unit B in algorithm as follows in step 4):
If it does not exist when the feature unit B of duplicate synchronous id, then circulation directly processing is jumped out;
If it exists when the feature unit B of duplicate synchronous id, then current signature unit A follows the synchronous duplicate feature unit of id Current thread enters slumber after B, and monitors whether feature unit B handles completion by thread counter.As feature unit B After the completion of processing, thread counter is triggered, feature unit A listens to the wake-up of event back, repeats the operation and continues to search queue Preceding whether there are also the synchronous duplicate feature unit C of id, until the duplicate feature unit of id is not present in front, then it represents that the unit exists It can be executed safely in this process.Such mode maximizing alleviates the slow problem of serial process data.
Specifically, if it exists cluster the case where, this method further include:
Step 5) is carried out locking waiting, is guaranteed not by zookeeper distributed lock, id synchronous to the feature unit that will be executed Only have one with the feature unit comprising same synchronous id in cluster executing;Feature unit is not punished after the completion of execution business For reason the result is that success or failure, discharges from queue, and then handles next unit, guarantee subsequent cell always can be normal It wakes up.
In goods entry, stock and sales software of the invention guarantee data thread safety method, abandoned it is traditional, be based on language tag The pervasive thread-safe realized guarantees that mode ensure that commodity stocks quantity, cost data is not specifically for procurement, sales, inventory business While mistake being generated because of multithreading concurrent, also improve as far as possible thread can concurrent feasibility, with tradition The mode that executes of core code single thread it is different, greatly improve the execution efficiency of procurement, sales, inventory business.
Detailed description of the invention
Fig. 1 is logic diagram of the present invention.
Specific embodiment
Embodiment 1: the method for the guarantee data thread safety of this example is based on windows or linux operating system, closes It is type database, zookeeper and the goods entry, stock and sales software based on java exploitation.Db transaction rank is set as " to weigh Re-reading repeatable-read " implements step are as follows:
It identifies the atomic transaction unit in procurement, sales, inventory business, there is any information unauthorized then to need all to carry out entire transaction units The service logic implementation procedure of " purchasing mono- preservation " is such as considered an atomic transaction unit by rolling back action.
Tenant's level queue is created according to tenant's NameSpace, queue is realized using LinkedList, due to different tenants Data are isolation, and parallel execute will not generate dirty data, so can not consider the problems of to execute parallel between different tenants.
Entire " buying order " business is made a feature object by dynamic proxy by typing " buying order " request, is stored in pair In the queue answered.Feature object unit has attribute:
Thread counter: whether the previous element that monitoring active cell is lined up is released;
Synchronous id set: can lead to the problem of the Data Identification of concurrent data, example: commodity id influences commodity stocks information;
Executor id: the thread name of binding, mark are which thread is executing.
Queue waits algorithm, and current signature unit (A) is appended to queue end after acquisition queue, circulation is started simultaneously at and looks into Element before looking for contains duplicate synchronous id with the presence or absence of feature unit (B).
If it does not exist, then jumping out circulation directly processing.
If it is present current signature unit (A) follows the synchronous duplicate feature unit of id (B), current thread enters afterwards Slumber, and whether completion is handled by thread counter monitoring feature unit (B).After the completion of feature unit (B) processing, Thread counter is triggered, feature unit (A) listens to the wake-up of event back, repeats whether also the operation continues to search before queue Synchronous the duplicate feature unit of id (C), until the duplicate feature unit of id is not present in front, then it represents that the unit is in this process It can execute safely.
It deposits in case of clusters, after the completion of above-mentioned steps, by zookeeper distributed lock, to the spy that will be executed The synchronous id of sign unit carries out locking waiting, guarantees that the unit comprising same synchronous id in different clusters only has one and executing;It is special No matter levying unit processing result after the completion of execution business is success or failure, discharge, and then handles next from queue Unit guarantees that subsequent cell always being capable of normal wakeup.

Claims (4)

1. guaranteeing the method for data thread safety in goods entry, stock and sales software, it is applied to commodity stocks data and cost data, this method It is characterized in that setting db transaction rank to " repeatable read repeatable-read ", realizes that steps are as follows:
1) it identifies the atomic transaction unit in procurement, sales, inventory business, there is any information unauthorized then all to return to entire transaction units Rolling operation;
2) tenant's level queue is created according to tenant's NameSpace, queue is realized using LinkedList;Each tenant is using During all can individually create oneself execution queue;
3) specific atoms transaction units business is passed through dynamic generation by the specific atomic transaction unit requests of typing Reason, is stored in corresponding queue;
4) queue waits algorithm, and current signature unit A is appended to queue end after obtaining queue, start simultaneously at circulation searching it Preceding element contains duplicate synchronous id with the presence or absence of feature unit B.
2. guaranteeing the method for data thread safety in goods entry, stock and sales software as described in claim 1, it is characterised in that step 3) Middle feature object has with properties:
Thread counter, that is, monitor whether the previous element that current atomic transaction unit is lined up is released;
Synchronous id set, that is, lead to the problem of the Data Identification of concurrent data;
Executor id, that is, the thread name bound identify the thread in execution.
3. guaranteeing the method for data thread safety in goods entry, stock and sales software as described in claim 1, it is characterised in that step 4) Middle queue waits the judgment rule of feature unit B in algorithm as follows:
If it does not exist when the feature unit B of duplicate synchronous id, then circulation directly processing is jumped out;
If it exists when the feature unit B of duplicate synchronous id, then current signature unit A follows the synchronous duplicate feature unit of id Current thread enters slumber after B, and monitors whether feature unit B handles completion by thread counter;
After the completion of feature unit B processing, thread counter is triggered, feature unit A listens to the wake-up of event back, repeats the behaviour It whether continues to search before queue there are also the synchronous duplicate feature unit C of id, until the duplicate feature unit of id is not present in front, Then indicate that the unit can execute safely in this process.
4. guaranteeing the method for data thread safety in goods entry, stock and sales software as described in claim 1, it is characterised in that if it exists The case where cluster, this method further include:
Step 5) is carried out locking waiting, is guaranteed not by zookeeper distributed lock, id synchronous to the feature unit that will be executed Only have one with the feature unit comprising same synchronous id in cluster executing;Feature unit is not punished after the completion of execution business For reason the result is that success or failure, discharges from queue, and then handles next unit, guarantee subsequent cell always can be normal It wakes up.
CN201910459192.5A 2019-05-29 2019-05-29 Guarantee the method for data thread safety in goods entry, stock and sales software Pending CN110175080A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910459192.5A CN110175080A (en) 2019-05-29 2019-05-29 Guarantee the method for data thread safety in goods entry, stock and sales software

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910459192.5A CN110175080A (en) 2019-05-29 2019-05-29 Guarantee the method for data thread safety in goods entry, stock and sales software

Publications (1)

Publication Number Publication Date
CN110175080A true CN110175080A (en) 2019-08-27

Family

ID=67695980

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910459192.5A Pending CN110175080A (en) 2019-05-29 2019-05-29 Guarantee the method for data thread safety in goods entry, stock and sales software

Country Status (1)

Country Link
CN (1) CN110175080A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100313208A1 (en) * 2009-06-03 2010-12-09 Apple Inc. Method and apparatus for implementing atomic fifo
US20120330913A1 (en) * 2011-06-24 2012-12-27 Salesforce.Com, Inc. Systems and methods for supporting transactional message handling
CN105700939A (en) * 2016-04-21 2016-06-22 北京京东尚科信息技术有限公司 Method and system for multi-thread synchronization in distributed system
CN107203560A (en) * 2016-03-18 2017-09-26 中国移动通信集团宁夏有限公司 Database, multiple database operation transaction consistency ensuring method and system
CN109739482A (en) * 2018-12-28 2019-05-10 杭州东信北邮信息技术有限公司 A kind of service logic execution system and method based on dynamic language

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100313208A1 (en) * 2009-06-03 2010-12-09 Apple Inc. Method and apparatus for implementing atomic fifo
US20120330913A1 (en) * 2011-06-24 2012-12-27 Salesforce.Com, Inc. Systems and methods for supporting transactional message handling
CN107203560A (en) * 2016-03-18 2017-09-26 中国移动通信集团宁夏有限公司 Database, multiple database operation transaction consistency ensuring method and system
CN105700939A (en) * 2016-04-21 2016-06-22 北京京东尚科信息技术有限公司 Method and system for multi-thread synchronization in distributed system
CN109739482A (en) * 2018-12-28 2019-05-10 杭州东信北邮信息技术有限公司 A kind of service logic execution system and method based on dynamic language

Similar Documents

Publication Publication Date Title
CN108446972A (en) Bank's Supervision of credit method, apparatus and fund position manage system
CN108804112B (en) Block chain settlement processing method and system
CN110728429B (en) Case distribution method, device, medium and computer equipment
CN104463611B (en) Agent administration system
CN110297866A (en) Method of data synchronization and data synchronization unit based on log analysis
Graham Issues in real-time data management
McLaughlin et al. A large scale study of the ethereum arbitrage ecosystem
Koca et al. Managing product rollovers
Everman et al. Improving the cost efficiency of large-scale cloud systems running hybrid workloads-A case study of Alibaba cluster traces
CA2804441C (en) Database performance analysis
JP2010529535A (en) System and Method for Managing Extended Functions Assigned to a Financial Information Presentation Device [Related Application Cross Reference] This application is based on US Provisional Patent Application No. 60 / 940,605 filed May 29, 2007, 35 USC 119 (e ) Claiming priority based on US patent application 12 / 025,267 filed on Feb. 4, 2008 claiming priority under the provisions of
CN106874080B (en) Data calculation method and system based on distributed server cluster
CN111666144A (en) Batch processing task execution method and system and machine room deployment system
EP3149589B1 (en) System and method for dynamic collection of system management data in a mainframe computing environment
CN114036174B (en) Data updating method, device, equipment and storage medium
CN109871394B (en) Full-distributed high-concurrency calculation method and device
CN107450975A (en) A kind of task executing method and device based on layering
US8027996B2 (en) Commitment control for less than an entire record in an in-memory database in a parallel computer system
CN110175080A (en) Guarantee the method for data thread safety in goods entry, stock and sales software
Nelson et al. Real time decision support: creating a flexible architecture for real time analytics
CA2747019A1 (en) Capturing and processing data generated in an erp interim phase
CN112861140B (en) Service data processing method and device and readable storage medium
CN115658320A (en) Service data processing method and related equipment
EP2601627B1 (en) Transaction processing system and method
CN116662287A (en) Log data security audit method, device, cloud server and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20190827

WD01 Invention patent application deemed withdrawn after publication